Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang: error: linker command failed with exit code 1 #50

Closed
joefazee opened this issue Jun 8, 2016 · 3 comments
Closed

clang: error: linker command failed with exit code 1 #50

joefazee opened this issue Jun 8, 2016 · 3 comments
Assignees

Comments

@joefazee
Copy link

joefazee commented Jun 8, 2016

I am trying to build a simple project with this library and so far no success yet. I think i am doing something.

I built the library with prefix set to --prefix=/usr/local/restclient-cpp.

I copied the sample code from the repo and tried to compile it with the flags below.

g++ -I /usr/local/restclient-cpp/include -std=c++11 main.cpp -o main -v

Below is the output.

`Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.11.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 264.3.102 -v -dwarf-column-info -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.3.0 -I /usr/local/restclient-cpp/include -stdlib=libc++ -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /Users/joefazee/Desktop/curl-test -ferror-limit 19 -fmessage-length 203 -stack-protector 1 -fblocks -fobjc-runtime=macosx-10.11.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/s9/w9447kdn4pd5b44ldn7xmxm80000gp/T/main-8a7637.o -x c++ main.cpp
clang -cc1 version 7.3.0 (clang-703.0.31) default target x86_64-apple-darwin15.4.0
ignoring nonexistent directory "/usr/include/c++/v1"

include "..." search starts here:

include <...> search starts here:

/usr/local/restclient-cpp/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1
/usr/local/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.3.0/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.11.0 -o main /var/folders/s9/w9447kdn4pd5b44ldn7xmxm80000gp/T/main-8a7637.o -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.3.0/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
"RestClient::del(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&)", referenced from:
_main in main-8a7637.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)`

@mrtazz
Copy link
Owner

mrtazz commented Jun 8, 2016

This sounds like you need to also pass -l restclient-cpp to g++ to make it link in the actual library.

@mrtazz mrtazz self-assigned this Jun 8, 2016
@joefazee
Copy link
Author

joefazee commented Jun 9, 2016

I tried that before posting the issue here.

**$ g++ -I /usr/local/restclient-cpp/include -l restclient-cpp -std=c++11 main.cpp -o main** ld: library not found for -lrestclient-cpp clang: error: linker command failed with exit code 1 (use -v to see invocation)

I ended up compiling with homebrew and it worked.

@mrtazz
Copy link
Owner

mrtazz commented Jun 9, 2016

oh ok, glad it worked in the end! Please reopen this or open a new issue if you run into any other problem.

@mrtazz mrtazz closed this as completed Jun 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants