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

ld: symbol(s) not found for architecture x86_64 #45

Closed
vhikd opened this issue Aug 10, 2013 · 15 comments
Closed

ld: symbol(s) not found for architecture x86_64 #45

vhikd opened this issue Aug 10, 2013 · 15 comments

Comments

@vhikd
Copy link

vhikd commented Aug 10, 2013

When I try to build on MacOS 10.8.4,it turns out this error message.

cc1plus: warning: command line option "-Wmissing-declarations" is valid for C/ObjC but not for C++
CXXLD sndfilehandle
ld: warning: ignoring file ../src/.libs/libsndfile.dylib, file was built for unsupported file format ( 0xce 0xfa 0xed 0xfe 0x c 0x 0 0x 0 0x 0 0x 9 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (x86_64): ../src/.libs/libsndfile.dylib
Undefined symbols for architecture x86_64:
"_sf_close", referenced from:
_main in sndfilehandle.o
"_sf_open", referenced from:
_main in sndfilehandle.o
"_sf_read_short", referenced from:
_main in sndfilehandle.o
"_sf_write_short", referenced from:
_main in sndfilehandle.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make[1]: *** [sndfilehandle] Error 1
make: *** [all-recursive] Error 1

@erikd
Copy link
Member

erikd commented Aug 10, 2013

It looks like you have object files or binaries from a previous build lying around. My suggestions is:

make clean
make
make check

@erikd
Copy link
Member

erikd commented Aug 21, 2013

Did the above suggestion work?

If I don't get a response, I'll close this in a week.

@vhikd
Copy link
Author

vhikd commented Aug 23, 2013

It doesn't work . I don't have any idea about it. I have given up three days ago. Thanks for your reply.

@erikd
Copy link
Member

erikd commented Sep 3, 2013

Closing this as there is insufficient information to do anything. Feel free to re-open if you can make more information available to me.

@erikd erikd closed this as completed Sep 3, 2013
@joagle
Copy link

joagle commented Oct 11, 2013

Hi,
I'm having a similar problem.
My context is that I am using CDT in eclipse, so I can not exclude the possibility that the problem is not inside of libsndfile.
Otherwise: Mac OS 10.8.5,
g++ -v produces:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.76) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin12.5.0
Thread model: posix

I created a test app the just tries to open a soundfile with sf_open.

Compilation seems to go fine, the problem arises when linking.
When I build the project, it aborts with the following message:


Building target: testlib
Invoking: MacOS X C++ Linker
g++ -L/usr/local/lib -o "testlib" ./src/testlib.o
Undefined symbols for architecture x86_64:
"_sf_open", referenced from:
_main in testlib.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: *** [testlib] Error 1


I installed libsndfile with homebrew - headers&libraries seem to be found OK in /usr/local/include and /usr/local/lib respectively.
When I checked the type of the library files with "file" I am getting:

libsndfile.dylib: Mach-O 64-bit dynamically linked shared library x86_64
libsndfile.a: current ar archive random library

(Not sure what that means for libsndfile.a)

@erikd
Copy link
Member

erikd commented Oct 11, 2013

The line:

g++ -L/usr/local/lib -o "testlib" ./src/testlib.o

needs to be told to link the libsndfile library ie:

g++ -L/usr/local/lib -lsndfile -o "testlib" ./src/testlib.o

@joagle
Copy link

joagle commented Oct 14, 2013

Thanks for the help out, I suspected it would be something basic like that :)

Just in case someone ends up here with the same development environment,
to configure the C++ Linker correctly under CDT/eclipse one has to enter "sndfile" in the text field found under:

Project->Properties->C/C++ Build->Settings->Mac OS C++ Linker->Libraries->"Libraries -l"
The "-l" gets added to "sndfile" automatically to create "-lsndfile"

Entering "/usr/local/lib" into "Library Search Path (-L)" was not necessary - evidently the linker looks there already by default.

It is also important however to point the Compiler to the correct include directory (containing "sndfile.h"). I guess most installations would install this into "/usr/local/include".
For a C++ project in CDT/eclipse this would need to be entered in

Project->Properties->C/C++ Build->Settings->GCC C++ Compiler->Includes->"Include paths (-l)"

Cheers,
J

@amruthanadarajan
Copy link

Hi!

I have the same issue. It cropped up all of a sudden. The same program I am trying to build now has been compiled/run before. My OS has been updated to Yosemite 10.10.

I tried fixing the issue both ways. I have linked the library in Xcode using the correct header search path. I made a fresh installation of libsndfile. It still doesn't fix the issue. I can provide any additional details necessary.

Context: I am trying to compile a program, that reads a wave file and prints info.
OS:Mac OS X Yosemite 10.10

Undefined symbols for architecture i386:
"_sf_close", referenced from:
SndfileHandle::SNDFILE_ref::~SNDFILE_ref() in main.o
"_sf_open", referenced from:
SndfileHandle::SndfileHandle(char const*, int, int, int, int) in main.o
"_sf_strerror", referenced from:
SndfileHandle::strError() const in main.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The id was ld: symbol(s) not found for architecture x86_64 initially. I changed the architecture it was building against in Xcode and hence the new error id shows i386.

Could you help me fix this issue? Been struggling with it for a long time.

@erikd
Copy link
Member

erikd commented Jul 18, 2015

@amruthanad You have given me error message but not the compile comand that produced this error. On your machine:

a) What command are you using to compile?
b) Where is libsndfile installed?
c) Is it installed binary the same architecture (ir x86_64 vs i386).

@amruthanadarajan
Copy link

a) I tried building it in Xcode as a part of a project. I could compile it from the command line using g++. What worked was: g++ -I/usr/local/include -lsndfile -o testwav testwav.c
When I try to build it as a project I get the aforementioned errors(in Xcode).

b) Libsndfile is installed in /usr/local/include directory.

c) I installed it exactly as described in README.md. I am new to using macOSX and also new to command line. I am not sure if its installed in the same architecture. Is there different install instructions for different architectures? (I have a macbook pro if that helps)

@erikd
Copy link
Member

erikd commented Jul 18, 2015

If you are building it with Xcode I can't help you. I do all my development on Linux and do not have any access to Mac OS.

However, your problem has nothing specifically to do with libsndfile and everything to do with Xcode. I suggest you seek Xcode help elesewhere.

@amruthanadarajan
Copy link

Thank you for your response. I figured that must be the case as it compiles just fine with g++. Maybe I will just stick to command line compilation.

@hasanfaizal
Copy link

Hi I do have the same problem and I am using the Eclipse to compile the project,

$ gcc -lssl -lcrypto -o /Users/KHF/Documents/Eclipse/workspace/Test\ EC/EC.c
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I had tried the above solution by pointing the location of sndfile.h and also added the same to the libraries. Yet the problems don't seems to be solved.

@amruthanadarajan
Copy link

Hey! Make sure you compile it as a library and link the library when you
compile the code you have written. I was using Xcode. I had to compile
libsndfile as a library (xcode project built) and then link it. I am not
sure how to do it in Eclipse but there must be some way.
On Feb 14, 2016 3:40 PM, "hasanfaizal" notifications@github.com wrote:

Hi I do have the same problem and I am using the Eclipse to compile the
project,

$ gcc -lssl -lcrypto -o /Users/KHF/Documents/Eclipse/workspace/Test
EC/EC.c
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see
invocation)


Reply to this email directly or view it on GitHub
#45 (comment).

@erikd
Copy link
Member

erikd commented Feb 14, 2016

@hasanfaizal From what I can see, it seems your problem has nothing to do with libsndfile and everything to do with Eclipse. Since I have never used Eclipse, you are much better off asking for help elsewhere. Sorry I can't be of more help.

@libsndfile libsndfile locked and limited conversation to collaborators Feb 14, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants