[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:
make: Leaving directory `/Users/cjr/Documents/development/qt/TestSSL-build-desktop'@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[])
{
QCoreApplication a(argc, 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.
-
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":http://dl.dropbox.com/u/23162179/libssl.dylib.zip.
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[])
{
QCoreApplication a(argc, 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 -lcryptoHEADERS += 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_64If 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? -
In my makefile the libs-line looks like this:
@LIBS = $(SUBLIBS) -F/Users/username/QtSDK/Simulator/Qt/gcc/lib -L/Users/username/QtSDK/Simulator/Qt/gcc/lib -framework QtGui -framework QtCore @
I don't know what $(SUBLIBS) stands for, but for the rest I think it should all be x86_64.
Anything else I should check? -
This is the output of the compiler pane:
@make: Entering directory `/Users/username/Documents/workspace/Qt/Ueb03-build-desktop'
/Users/username/QtSDK/Desktop/Qt/473/gcc/bin/qmake -spec ../../../../QtSDK/Desktop/Qt/473/gcc/mkspecs/macx-g++
<QMLJSDEBUGGER_PATH=/Users/username/QtSDK/Qt\ Creator.app/Contents/Resources/qml/qmljsdebugger -o Makefile ../Ueb03/Ueb03.pro
@
(End of part 1) -
(Part 2)
@make: Leaving directory/Users/username/Documents/workspace/Qt/Ueb03-build-desktop' 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...
-
This should probably work. I cannot see the external framework that you link to.
I never installed the SDK version of the Qt libs, so I don't know if those contain a x86_64 version. You might want to check the output of
@
lipo -info /Users/username/QtSDK/Desktop/Qt/473/gcc/lib/QtGui.framework/QtGui
lipo -info /Users/username/QtSDK/Desktop/Qt/473/gcc/lib/QtCore.framework/QtCore
@it should contain x86_64