restclient-cpp icon indicating copy to clipboard operation
restclient-cpp copied to clipboard

Error: Undefined symbols for architecture x86_64

Open voidabhi opened this issue 8 years ago • 19 comments

Command

$ make

Environment

OSX Yosemite 10.10.2
GNU Make 3.81
gxx version 6.1.0 

Error

Undefined symbols for architecture x86_64:
  "RestClient::post(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)"
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

voidabhi avatar Mar 07 '16 13:03 voidabhi

can you give some more details about your environment and the command you ran that resulted in this error?

mrtazz avatar Mar 07 '16 14:03 mrtazz

@mrtazz updated!

voidabhi avatar Mar 08 '16 05:03 voidabhi

do you get any errors for ./autogen.sh or ./configure? Did you pass any flags to configure?

mrtazz avatar Mar 08 '16 15:03 mrtazz

Ya these both are working fine. In configure i had passed --prefix flag for storing the lib in my thirdparty directory

voidabhi avatar Mar 09 '16 06:03 voidabhi

I have the same problem. @voidabhi your target is universal binary x86(_64) and the lib is built for x64 only. It builds OK for 64bit targets.

I apologise for the noob question - how do I build the lib for both 32 and 64bit?

nicroto avatar Apr 06 '16 14:04 nicroto

oh, sorry for the long delay. I will have to check how to compile it for both architectures.

mrtazz avatar Apr 19 '16 22:04 mrtazz

@mrtazz thanks.

nicroto avatar Apr 20 '16 08:04 nicroto

It seems like you can pass -arch i386 -arch x86_64 to clang to build a multi architecture binary (as per http://stackoverflow.com/questions/6104726/trouble-building-universal-binary-with-autotools). There are also the -m flags to gcc you could try to, however this post (http://stackoverflow.com/questions/3261909/build-32bit-on-64-bit-linux-using-an-automake-configure-script) is for Linux so I'm not super confident in it working on OSX.

mrtazz avatar Apr 20 '16 13:04 mrtazz

@nicroto @voidabhi can you give those instructions a try and see if they work for you? Happy to add an autoconf flag for this if this is all that's needed to make this work.

mrtazz avatar May 02 '16 14:05 mrtazz

@mrtazz Getting same error on running cmake with above flags

cmake "-DCMAKE_OSX_ARCHITECTURES=x86_64;i386" ..

reference

voidabhi avatar May 03 '16 07:05 voidabhi

Having the same issue as him "Undefined symbols for architecture x86_64: "RestClient::get(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&)"

thefiend avatar Mar 11 '18 04:03 thefiend

Having also the same issue as him "Undefined symbols for architecture x86_64: "RestClient::get(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&)"

aschafers avatar Apr 26 '20 23:04 aschafers

@aschafers are you still having issues with the latest code? I'd like to know if this can be closed. Thanks!

edwinpjacques avatar Nov 01 '20 00:11 edwinpjacques

Hello, I tried yesterday to use rest client on a mac and I am having exactly the same issue:

Undefined symbols for architecture x86_64:
  "RestClient::get(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      _main in main.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

is there any way to fix it?

fmachi avatar Nov 18 '20 10:11 fmachi

I have the same problem on mac 10.15.7

lpxxn avatar Dec 10 '20 14:12 lpxxn

Same here, is there any solution yet?

ae94 avatar Sep 24 '21 01:09 ae94

I am having the same issue on Linux with clang. It seems that this specific template instance isn't being compiled: error: mold: error: undefined symbol: build/linux/x86_64/release/libcryptobot.a(server.cpp.o): RestClient::get(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) If this is the case there should be a way to make the compiler deduce this instantiation. As a matter of fact, this instance shouldn't be needed at all in my code, at least at a first glance, since I'm only calling auto REST_response = RestClient::get(json_request);.

aacirino avatar Jan 20 '22 18:01 aacirino

i have the same for arm64 on m1 macbook

isyuck avatar Aug 14 '22 15:08 isyuck

Hello! I fought the decision for CMake. I use MacOS Ventura 13.4. You may add this code into your CMake:

FetchContent_Declare(
    restclient
    GIT_REPOSITORY https://github.com/mrtazz/restclient-cpp.git
    GIT_TAG        master 
)

FetchContent_MakeAvailable(restclient)
FetchContent_GetProperties(restclient)
if(NOT restclient_POPULATED)
    FetchContent_Populate(restclient)
endif()

list(APPEND EXTRA_LINKS
    restclient-cpp )
target_link_libraries(${PROJECT_NAME}
    ${EXTRA_LINKS})

SozonovAA avatar Dec 02 '23 17:12 SozonovAA