[Moved] symbol(s) not found for architecture x86_64
Hi,
I’m using Qt Creator 2.1.0 (based on Qt 4.7.1 64 bit) on my Apple Mac, and I’ve run into a build problem when trying to reference symbol EVP_sha1() which resides in libssl.dylib. I get the following error:
- Undefined symbols for architecture x86_64:
- "_EVP_sha1", referenced from:
In my .pro file, I have the line:
- LIBS += -L/usr/lib -lssl
and my code is:
- #include <QtCore/QCoreApplication>
- #include <openssl/sha.h>
- #include <openssl/hmac.h>
- int main(int argc, char *argv[])
- {
- unsigned char *key = (unsigned char *)"MySecretKey";
- unsigned char *message = (unsigned char *)"FakeRequestDescription";
- unsigned char out[30];
- unsigned int len = 0;
- HMAC(EVP_sha1(),
- key,
- 11,
- message,
- 22,
- out,
- &len);
- return a.exec();
- }
Using nm on the libssl.dylib shows the following output:
- MacBook-Pro:lib cjr$ file libssl.dylib
- libssl.dylib: Mach-O universal binary with 3 architectures
- libssl.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
- libssl.dylib (for architecture i386): Mach-O dynamically linked shared library i386
- libssl.dylib (for architecture ppc7400): Mach-O dynamically linked shared library ppc
Does anyone have any ideas on what I can do to get this working?
Thanks.
15 replies
Very strange. It works for me:
- LIBS += -lssl -lcrypto
No additional paths (/usr/lib is in the list anyways) and with pure x86_64 build (no i386, no ppc). Can you upload /usr/lib/libssl.dylib (resp. the file that symlink points to) somewhere? I’ll have a look at it and will compare it against that in my system (OS X 10.6.7).
Ah, and can you post the output of the compilation, please. I’d like to know how the compiler is acutally called.
I moved this thread to the Tools forum, as it’s not Qt related.
Thanks for your help.
I’ve placed the file here [dl.dropbox.com].
Unsure if it is important but the version of the library in /usr/lib is larger than the one in /Developer/SDKs/MacOSX10.6.sdk/usr/lib
The output of the compilation is as follows:
Running build steps for project TestSSL…
Configuration unchanged, skipping qmake step.
Starting: “/usr/bin/make” -w
make: Entering directory `/Users/cjr/Documents/development/qt/TestSSL-build-desktop’
g++ -c -pipe -g -gdwarf-2 -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_CORE_LIB -I../../../../QtSDK/Desktop/Qt/473/gcc/mkspecs/macx-g++ -I../TestSSL -I../../../../QtSDK/Desktop/Qt/473/gcc/lib/QtCore.framework/Versions/4/Headers -I../../../../QtSDK/Desktop/Qt/473/gcc/include/QtCore -I../../../../QtSDK/Desktop/Qt/473/gcc/include -I. -I../TestSSL -I. -F/Users/cjr/QtSDK/Desktop/Qt/473/gcc/lib -o main.o ../TestSSL/main.cpp
g++ -headerpad_max_install_names -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -o TestSSL main.o -F/Users/cjr/QtSDK/Desktop/Qt/473/gcc/lib -L/Users/cjr/QtSDK/Desktop/Qt/473/gcc/lib /Developer/SDKs/MacOSX10.6.sdk/usr/lib/libssl.dylib -framework QtCore
Undefined symbols for architecture x86_64:
“_EVP_sha1”, referenced from:
make: Leaving directory `/Users/cjr/Documents/development/qt/TestSSL-build-desktop’
_main in main.o
“_HMAC”, referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [TestSSL] Error 1
The process “/usr/bin/make” exited with code 2.
Error while building project TestSSL (target: Desktop)
When executing build step ‘Make’
Ok, found the error. The files are identical (bitwise), so no need to worry about this. You seem to have in your .pro something like this:
- LIBS += /Developer/SDKs/MacOSX10.6.sdk/usr/lib/libssl.dylib
This is wrong. The files in the SDKs subdirs are only library stubs, the do not contain actual code (so we found the reason why they’re smaller than those in /usr/lib).
Please replace the line above by
- LIBS += -lssl -lcrypto
And have a look if you have other references to that SDK dir, other than
- QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.6.sdk
If you do have, please remove them too.
This is a complete small project that works for me:
——— test.pro ———
- QT -= core
- TARGET = SimpleConsoleTest
- CONFIG += console
- CONFIG -= app_bundle
- CONFIG += x86_64
- CONFIG -= i386
- TEMPLATE = app
- LIBS += -lssl -lcrypto
- SOURCES += main.cpp
——— main.cpp ———
- #include <QtCore/QCoreApplication>
- #include <QtCore/QDebug>
- #include <openssl/sha.h>
- #include <openssl/hmac.h>
- int main(int argc, char *argv[])
- {
- unsigned char *key = (unsigned char *)"MySecretKey";
- unsigned char *message = (unsigned char *)"FakeRequestDescription";
- unsigned char out[30];
- unsigned int len = 0;
- qDebug() << "key:" << (char*)key;
- qDebug() << "msg:" << (char*)message;
- HMAC(EVP_sha1(),
- key,
- 11,
- message,
- 22,
- out,
- &len);
- qDebug() << "out:" << (char*)out;
- return 0;
- }
Hi,
for some reason I’m having the same problem as calumcjr. I’m using Qt 4.7.3 on my Mac (OS X.6.7).
I tried to run my project from Qt Creator and from eclipse but I keep getting the above mentioned error message.
Background: I need to implement a few functionalities into a given framework that wasn’t created by myself.
As the framework is quite large, I think it’s not useful to post it here. And as the above mentioned problem could be solved by modifying the pro-file I think that’s where my problem might be as well.
So here’s my pro-file:
- #-------------------------------------------------
- #
- # Project created by QtCreator 2011-06-17T13:45:15
- #
- #-------------------------------------------------
- QT += core gui
- TARGET = Ueb03
- TEMPLATE = app
- DEPENDPATH += . src
- INCLUDEPATH += . src
- CONFIG -= app_bundle
- CONFIG += x86_64
- CONFIG -= i386
- LIBS += -lssl -lcrypto
- HEADERS += src/Geometry.h \
- src/MainWindow.h \
- src/Model.h \
- src/MovingBox.h \
- src/RollingBall.h \
- src/RotatingCow.h \
- src/RotationWidget.h
- SOURCES += src/Geometry.cpp \
- src/main.cpp \
- src/MainWindow.cpp \
- src/Model.cpp \
- src/MovingBox.cpp \
- src/RollingBall.cpp \
- src/RotatingCow.cpp \
- src/RotationWidget.cpp
I made a few modifications according to the sampe pro file. Yet I get this error message:
error: symbol(s) not found for architecture x86_64
If you need any further information, please let me know.
Thanks a lot in advance.
thisaintme, it’s not clear in what step and which object file the architecture is missing. Please check those with
- file name-of-file-or-lib
it should print out all the architectures that are contained in your file.
First start with the lib you are linking to. You must have the same architectures (or less), but no more additional ones in your project.
Hi Volker,
here’s what I get when running the file-command:
- Geometry.o: Mach-O 64-bit object x86_64
- MainWindow.o: Mach-O 64-bit object x86_64
- Model.o: Mach-O 64-bit object x86_64
- MovingBox.o: Mach-O 64-bit object x86_64
- RollingBall.o: Mach-O 64-bit object x86_64
- RotatingCow.o: Mach-O 64-bit object x86_64
- RotationWidget.o: Mach-O 64-bit object x86_64
- main.o: Mach-O 64-bit object x86_64
- moc_MainWindow.o: Mach-O 64-bit object x86_64
- moc_MovingBox.o: Mach-O 64-bit object x86_64
- moc_RollingBall.o: Mach-O 64-bit object x86_64
- moc_RotatingCow.o: Mach-O 64-bit object x86_64
- moc_RotationWidget.o: Mach-O 64-bit object x86_64
So it looks like the linked objects all are x86_64.
Any idea, what the problem might be?
(Part 2)
- make: Entering directory `/Users/username/Documents/workspace/Qt/Ueb03-build-desktop'
- g++ -headerpad_max_install_names -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -o Ueb03.app/Contents/MacOS/Ueb03 Geometry.o main.o MainWindow.o Model.o MovingBox.o RollingBall.o RotatingCow.o RotationWidget.o moc_MainWindow.o moc_MovingBox.o moc_RollingBall.o moc_RotatingCow.o moc_RotationWidget.o -F/Users/username/QtSDK/Desktop/Qt/473/gcc/lib -L/Users/username/QtSDK/Desktop/Qt/473/gcc/lib -framework QtGui -framework QtCore
I don’t know exactly where linking part comes but I don’t see any files or libraries that are not x86_64…
You must log in to post a reply. Not a member yet? Register here!


