linker

C/cmake - how to add a linker flag to an (unused) library when the library is specified in TARGET_LINK_LIBRARIES?

霸气de小男生 提交于 2019-12-23 10:08:56
问题 In the root directory of my project, I have a subdirectory for my_lib and another for my_app . The library my_lib defines tables that populates a section defined by the linker, these tables are not used directly by my_app , so this library is not linked. To force my_lib to be linked I added the flag --whole-archive as described here. And it works! In the CMakelist.txt of the root directory I have the following: SET(CMAKE_EXE_LINKER_FLAGS "-mmcu=cc430f6137 -Wl,--gc-sections -Wl,--whole-archive

Under which circumstances will a C Linker eliminate unused volatile symbols?

时光怂恿深爱的人放手 提交于 2019-12-23 09:58:06
问题 I am using a very specific toolchain (SHARC DSP Processor from Analog Devices) and I would like to get a better understanding of my compiler/linker. I have somewhere a volatile global variable: volatile long foo; This variable is not used and not referenced in my code but I want to preserve it in my final executable (don't ask me why, the sad truth is sad). I usually link my project with the -e option. It tells the linker to remove dead code from the executable. I initially thought no

Undefined reference to MySQL libraries using g++

牧云@^-^@ 提交于 2019-12-23 09:55:44
问题 I am getting undefined reference to 'mysql_suchandsuch@#' messages when trying to link my program with the MySQL libraries supplied with the 5.5 server. When MySQL was installed, I used the default path, which for me on Windows is C:\Program Files\MySQL\MySQL Server 5.5\ . Originally, I had thought that the spaces are causing my grief, but I think I've correctly worked out how to point to the library path without spaces (still with no luck). If there's another probable cause, please let me

Missing crt1 and crti when crosscompiling

南笙酒味 提交于 2019-12-23 09:49:39
问题 I'am trying to build a cross compile toolchain based on GCC4.5 and newlib with gold and link-time-optimization enabled. GCC compiles fine but it did not generate the crt1.o or crti.o files. Therefore when I tries to use the compiler for building Newlib it complains with the message: ld: error: cannot open crti.o: No such file or directory ld: error: cannot open crtn.o: No such file or directory ld: error: cannot find -lc When searching for files named crt* in the directory where GCC4.5 is

Renaming symbols at compile time without changing the code in a cross platform way

白昼怎懂夜的黑 提交于 2019-12-23 09:18:13
问题 In creating a static object is it possible to rename the symbols at compile time (without changing the code) in a cross platform way? I have recently had objcopy recommended, but linux is not the only target platform it must also work on a mac. I am compiling using gcc, so I was hoping that there was a gcc option of some sort. I have heard about .def files, but this may have been misleading as the information about them that I have found seems to be for windows. Edit: I'm trying to change the

How to remove unused .CONST data in MASM?

孤者浪人 提交于 2019-12-23 08:52:19
问题 I'm using macros in MASM to generate about 2000 functions, for each of which I define a string, but I only use around ~30 of them in any given program. (There is no way to predict which ones I will use ahead of time; I use them as needed.) Is there any way to tell the linker to "strip out" the strings that I don't end up using? They blow up the binary size by quite a lot. 回答1: Why don't you just put those 2000 functions and strings into a static library? Make the procs public, and use

cmake generated Xcode-project - release-build works but archive fails on linker errors

旧街凉风 提交于 2019-12-23 08:36:51
问题 Using Xcode 6.3.1, CMake 3.2.2 I have a project which links with a library. This library is included in the xcode-project as code, compiled and then linked with the main executable. The project is generated with cmake. Some extracts of the CMakeLists.txt: add_library(mylib ${mylib_HEADERS} pch.cpp source/mylib/xxx.cpp) ... add_executable(${MAIN_BINARY_NAME} MACOSX_BUNDLE ${MAIN_HEADERS} ${MAIN_CODE_FILES} ${MAIN_ICON_FILES} ${MAIN_DYLIBS} ) target_link_libraries (${MAIN_BINARY_NAME} mylib)

ld: duplicate symbol

天涯浪子 提交于 2019-12-23 07:47:02
问题 I'm working on a school project and I'm getting some weird errors from Xcode. I'm using TextMate's Command+R function to compile the project. Compilation seems to work okay but linking fails with an error message I don't understand. ld output: ld: duplicate symbol text_field(std::basic_istream >&)in /path/final/build/final.build/Release/final.build/Objects-normal/ppc/generics.o and /path/final/build/final.build/Release/final.build/Objects-normal/ppc/main.o collect2: ld returned 1 exit status

Can I ask VC++ linker to ignore unresolved externals?

天大地大妈咪最大 提交于 2019-12-23 07:44:41
问题 I'm trying to build a very complex open-source project with VC++. The project consists of dozens of libraries and one executable depending on those libraries. For some reasons VC++ linker doesn't want to see about 40 functions implemented in one of those libraries and reports "unresolved external reference" on each, so I can't link. I don't want to waste time resolving the problem - those functions are likely never called. I'd like to just ask the linker to link what it sees and insert some

Can I ask VC++ linker to ignore unresolved externals?

纵然是瞬间 提交于 2019-12-23 07:44:38
问题 I'm trying to build a very complex open-source project with VC++. The project consists of dozens of libraries and one executable depending on those libraries. For some reasons VC++ linker doesn't want to see about 40 functions implemented in one of those libraries and reports "unresolved external reference" on each, so I can't link. I don't want to waste time resolving the problem - those functions are likely never called. I'd like to just ask the linker to link what it sees and insert some