I've littered through Stackoverflow trying to get Unity unit test framework (https://www.throwtheswitch.org/unity) linked and built on CMAKE so that I can write unit tests but I keep hitting this same error:
Undefined symbols for architecture x86_64:
"_setUp", referenced from:
_UnityDefaultTestRun in libunity.a(unity.c.o)
"_tearDown", referenced from:
_UnityDefaultTestRun in libunity.a(unity.c.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [bin/test_problem2_59.exe] Error 1
make[1]: *** [tests/CMakeFiles/test_problem2_59.exe.dir/al
I have documented my final attempt here https://github.com/aamarin/computer_systems/tree/dev with the latest commit being the unstable commit. I'm not sure what else I'm missing in computer_systems/tests/CMakeLists.txt to get this working. Just looking for some guidance and maybe an explanation I might be missing from here https://gitlab.com/CLIUtils/modern-cmake/-/blob/master/examples/extended-project/src/CMakeLists.txt. Guidance on better structuring my folder structure is helpful as well.
Just add empty functions named setUp and teadDown. UnityGettingStartedGuide.
Related
I've downloaded the latest release of libzip and am currently trying to build it on OSX and failing:
Linking C shared library libzip.dylib
Undefined symbols for architecture x86_64:
"_crc32", referenced from:
__zip_filerange_crc in zip_filerange_crc.o
_crc_read in zip_source_crc.o
_decrypt in zip_source_pkware.o
__zip_string_crc32 in zip_string.o
(maybe you meant: __zip_string_crc32)
"_deflate", referenced from:
_compress_read in zip_source_deflate.o
(maybe you meant: _zip_source_deflate)
"_deflateEnd", referenced from:
_deflate_compress in zip_source_deflate.o
"_deflateInit2_", referenced from:
_deflate_compress in zip_source_deflate.o
"_inflate", referenced from:
_decompress_read in zip_source_deflate.o
"_inflateEnd", referenced from:
_deflate_decompress in zip_source_deflate.o
"_inflateInit2_", referenced from:
_deflate_decompress in zip_source_deflate.o
"_zError", referenced from:
__zip_error_strerror in zip_error_strerror.o
_zip_error_to_str in zip_error_to_str.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [libzip.3.0.dylib] Error 1
make[2]: *** [CMakeFiles/zip.dir/all] Error 2
make[1]: *** [CMakeFiles/zip.dir/rule] Error 2
make: *** [zip] Error 2
It needs a crc32 function but it doesn't include one nor does it seem to link to anything else. Has anyone been able to build libzip on OSX 10.9?
You seem to be missing to link a against libz.
Get the developer files for zlib somewhere and add -lz to the (end of the command line of the) link command.
I am currently trying to install rng-tools on OSX, as I have a specific need for it to speed up a certain simulator that I am currently using. At first, I faced the problem of not having argp, so I installed argp-standalone from Homebrew. However, I still receive the following error message when trying to make rng-tools:
gcc -g -O2 -o rngtest stats.o rngtest.o librngd.a
Undefined symbols for architecture x86_64:
"_argp_parse", referenced from:
_main in rngtest.o
"_argp_usage", referenced from:
_parse_opt in rngtest.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make[2]: *** [rngtest] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
I checked /usr/local/include/argp.h and it does seem to contain the correct function definitions referenced in rngtest.c, so any thoughts on what might be the problem?
I just needed rngtest which I managed to compile on OSX using this https://github.com/fproulx/rngtest (which also needs brew install argp-standalone). I made that into a homebrew formula which can be obtained here: https://github.com/oderwat/homebrew-experiments
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_Reachability", referenced from:
objc-class-ref in FirstViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I've looked over FirstViewController, reachability.h and reachability.m - It's clearly defined! And I've even added SystemConfiguration.Framework, as well as Reachability.m is in the compile list.
Any ideas? I'm losing my mind!
Pic attached.
http://i.imgur.com/uw4Zb.png
Try to remove references to Reachability.h and Reachability.m files from your xCode project. - Make sure it disappears from Compile Sources.
Search you project's folder to make sure you don't have duplicates for Reachability.h and Reachability.m files in it
Command+Shift+K to clean the project;
Add Reachability.h and Reachability.m back to the xCode project;
Hope this will help.
I'm totally new to cmake. After an svn update (but also to binutils and I suspect this is causing the problem), I get an error (I successfully compiled and used the program before)
Linking CXX executable gmsh
/usr/bin/ld: /usr/local/lib/liblapack.a(dgesvd.o): undefined reference to symbol '_gfortran_concat_string##GFORTRAN_1.0'
/usr/bin/ld: note: '_gfortran_concat_string##GFORTRAN_1.0' is defined in DSO /usr/lib/libgfortran.so.3 so try adding it to the linker command line
/usr/lib/libgfortran.so.3: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
make[2]: *** [gmsh] Error 1
make[1]: *** [CMakeFiles/gmsh.dir/all] Error 2
make: *** [all] Error 2
Maybe it's related to this Fedoraproject DSO Change?
I have an up-to-date archlinux (binutils-2.23-1).
I tried to edit lines in the ccmake . menu. After hitting [c] the original options are restored (so I cannot add /usr/lib/libgfortran.so.3 to the GMSH_EXTERNAL_LIBRARIES variable in order [g] generate the new Makefiles).
I also tried adding some options which were recommended in the cmake irc chat, but it eventually didn't work.
cmake . -DCMAKE_LINK_FLAGS=-Wl,--add-needed
or
cmake . -DCMAKE_LINK_FLAGS=-lgfortran
Resulting in the same error. What can I do?
Additional information: make VERBOSE=1 pastebin link
To add a library to the link command, you can use target_link_libraries. Apparently in this case you want:
target_link_libraries(gmsh ${LINK_LIBRARIES} gfortran)
My code is identical to this question I asked earlier so there's no point in duplicating it here
This is the error I am getting:
Undefined symbols for architecture x86_64:
"_stdscr", referenced from:
_screen_init in screen.o
"_werase", referenced from:
_screen_init in screen.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I've had this error in the past and I feel like it has something to do with a duplicate function name or something, but I have no idea how to debug this.
EDIT:
After adding the libncurses.dylib file to my project, the errors discussed above have disappeared, but a new error has emerged when I call screen_init(); in my main.cpp:
// main.cpp
#include "screen.h"
int main(){
screen_init();
}
// new error
Undefined symbols for architecture x86_64:
"screen_init()", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Pretty much the same error except now in my main. Is there another library I am missing? These errors are very mysterious and not very helpful.
I guess you need to add the library to your link phase, if you are going with XCode you should add it in project details:
choose project details
choose build phases tab
open link binary with libraries part
click the plus symbol
add libncurses.dylib to your project.