View Issue Details [ Jump to Notes ] | [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
0009556 | CMake | CMake | public | 2009-09-17 11:00 | 2016-06-10 14:31 | ||||
Reporter | Keith Gardner | ||||||||
Assigned To | Bill Hoffman | ||||||||
Priority | normal | Severity | minor | Reproducibility | always | ||||
Status | closed | Resolution | moved | ||||||
Platform | OS | OS Version | |||||||
Product Version | CMake-2-6 | ||||||||
Target Version | Fixed in Version | ||||||||
Summary | 0009556: Linker Flags are not being pass for static libs in Visual Studio | ||||||||
Description | When specifying specific linker flags for a static library target, the flags are being ignored. If I change the project to a shared library or an executable, the flags are passed like normal. | ||||||||
Tags | No tags attached. | ||||||||
Attached Files | |||||||||
Relationships | |
Relationships |
Notes | |
(0017589) Bill Hoffman (manager) 2009-09-17 11:44 |
That is because static libraries are not "linked"... What are you trying to do? |
(0017590) Keith Gardner (reporter) 2009-09-17 11:52 |
I received an error on a project that stated that it could not identify the machine type and was defaulting to x86. This was all well and good until I needed to build the project as x64. I was able to specify the /MACHINE:x64 inside the solution but it was removed every time I reran CMake. I need to specify this flag so that our automated build server can compile the project. |
(0017591) Bill Hoffman (manager) 2009-09-17 12:10 |
Strange, we can build CMake 64 bit and it has a static library. |
(0017593) Keith Gardner (reporter) 2009-09-17 12:13 |
I have probably 20 different libraries that we make at work and only one has this issue. They all have the same configuration and have the same macros run against them but this one library has this issue. All I am saying is even though it doesn't make sense to have linker flags, having that functionality available would be good for fixing unexpected problems like this. |
(0024596) Maddes (reporter) 2011-01-11 15:36 edited on: 2011-01-15 13:15 |
This issue is very important to me. The static library I build calls functions from a Hardware Driver DLL. I want to link it with the DLL import lib of the Hardware Driver DLL. This way users of my static library do not need the DLL import lib for building their projects. I expected that values of link_directories() and target_link_libraries() would be added to the "Librarian -> General" section of VS2005/2008 configurations. Unfortunately this is not the case and I have to manually edit the project files. These link libraries should not be added to other targets, which link with this static library (as they are already inside the static lib). Also tried a workaround with STATIC_LIBRARY_FLAGS but that failed too :( set(STATIC_LIBRARY_FLAGS ${STATIC_LIBRARY_FLAGS} /LIBPATH:"C:\usr\local\lib" ${libraries}) |
(0024720) Maddes (reporter) 2011-01-15 14:02 edited on: 2011-01-15 14:04 |
After reading lots of articles on MSDN and elsewhere: You are right that's not a linker step, but a library step. IMHO "link_directories()", "target_link_libraries()" and target property LINK_FLAGS should also apply to a library step, as it just places these libs inside the output library in some way. Or provide "lib_directories()" and "target_lib_libraries()" for static library builds, maybe provide a target property LIB_FLAGS too. MSDN infos about LIB command and project file extracts: * VC6: http://msdn.microsoft.com/en-us/library/aa270431%28v=VS.60%29.aspx [^] , see "Running LIB" and "Managing a Library" !IF "$(CFG)" == "pinproc - Win32 Release" ... # ADD BASE LIB32 /nologo # ADD LIB32 ftd2xx.lib /LIBPATH:"\usr\local\lib\Release" /LIBPATH:"\usr\local\lib" /nologo /out:".\Release/libpinprocmt.lib" ... * VS2002+: http://msdn.microsoft.com/en-us/library/7ykb2k5f.aspx [^] , see "Running LIB" and "Managing a Library" <VisualStudioProject> <Configurations> <Configuration> <Tool Name="VCLibrarianTool" AdditionalDependencies="ftd2xx.lib" AdditionalLibraryDirectories="\usr\local\lib\$(OutDir),\usr\local\lib" OutputFile="$(OutDir)\libpinprocmtd.lib" /> </Configuration> |
(0024722) Maddes (reporter) 2011-01-15 18:11 |
The same is not possible with GCC (here MinGW). I tried to add the "target_link_libraries()" to the AR.EXE command, but they will not be recognized when the resulting static library is used in another project. Seems the functionality mentioned above in note 0024720 would only be MSVC only. Still it would be a great feature for MSVC users. |
(0025158) James Bigler (developer) 2011-01-28 16:51 |
I also just ran into this issue. I want to compile my code with /GL (link time code generation), but when the static library is created I get the following error: Creating command line "lib.exe @"c:\code\build-32-vs9-c32\src\stitch.dir\Release\RSP0006AF15525948.rsp" /NOLOGO" MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance That's fine. I can add that flag in the GUI in the "Command Line" section of the "Librarian" and this phase of the compile completes without warnings. However, I'm stumped to figure out how to get this flag added by default by CMake. |
(0025429) Johan Björk (reporter) 2011-02-15 06:35 |
James, You can set STATIC_LIBRARY_FLAGS for each add_library() target to work around this. I just asked on the e-mail list for a global property. (If you have many targets, you can override the add_library() function) |
(0041594) Kitware Robot (administrator) 2016-06-10 14:27 |
Resolving issue as `moved`. This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page. |
Notes |
Issue History | |||
Date Modified | Username | Field | Change |
2009-09-17 11:00 | Keith Gardner | New Issue | |
2009-09-17 11:44 | Bill Hoffman | Note Added: 0017589 | |
2009-09-17 11:52 | Keith Gardner | Note Added: 0017590 | |
2009-09-17 12:10 | Bill Hoffman | Note Added: 0017591 | |
2009-09-17 12:10 | Bill Hoffman | Status | new => assigned |
2009-09-17 12:10 | Bill Hoffman | Assigned To | => Bill Hoffman |
2009-09-17 12:13 | Keith Gardner | Note Added: 0017593 | |
2011-01-11 15:36 | Maddes | Note Added: 0024596 | |
2011-01-11 15:37 | Maddes | Note Edited: 0024596 | |
2011-01-11 15:38 | Maddes | Note Edited: 0024596 | |
2011-01-15 13:15 | Maddes | Note Edited: 0024596 | |
2011-01-15 14:02 | Maddes | Note Added: 0024720 | |
2011-01-15 14:02 | Maddes | Note Edited: 0024720 | |
2011-01-15 14:03 | Maddes | Note Edited: 0024720 | |
2011-01-15 14:04 | Maddes | Note Edited: 0024720 | |
2011-01-15 18:01 | Maddes | Note Added: 0024721 | |
2011-01-15 18:03 | Maddes | Note Deleted: 0024721 | |
2011-01-15 18:11 | Maddes | Note Added: 0024722 | |
2011-01-28 16:51 | James Bigler | Note Added: 0025158 | |
2011-02-15 06:35 | Johan Björk | Note Added: 0025429 | |
2016-06-10 14:27 | Kitware Robot | Note Added: 0041594 | |
2016-06-10 14:27 | Kitware Robot | Status | assigned => resolved |
2016-06-10 14:27 | Kitware Robot | Resolution | open => moved |
2016-06-10 14:31 | Kitware Robot | Status | resolved => closed |
Issue History |
Copyright © 2000 - 2018 MantisBT Team |