From: Hendrik W. <we...@im...> - 2009-06-22 16:36:05
|
Hi! I'm trying to compile my OpenMS project, but keep getting a linker error that's driving me nuts. Maybe one of you can help me. The project I'm trying to compile consists of four files: 1. main.C - containing the executable 2./3. PepXMLFile.h and PepXMLFile.C - improved version of the OpenMS class that I want to test using main.C 4. helpers.h - containing small helper functions that are used in both main.C and PepXMLFile.C I've listed those files under "my_sources" in the CMakeLists.txt; "my_executables" contains only "main". main.C and PepXMLFile.C both include PepXMLFile.h. The problem is with helpers.h: When I try to build the project via "make main", it compiles just fine, but the linker produces "multiple definition" errors for the functions in helpers.h. This happens regardless of if I include helpers.h in both .C files or only in PepXMLFile.h. (If I include it only in PepXMLFile.C, the helper functions that I use in main.C are not defined.) To me, the underlying issue seems to be that CMake generates two independent object files PepXMLFile.C.o and main.C.o, both containing definitions for the helper functions (I assume). Then, it tries to link both object files to produce the executable, and that's where the errors occur. If anyone has come across a similar problem, I'd be grateful for your advice. Cheers Hendrik |