"symbol(s) not found for architecture x86_64" error when compiling a Qt project on Mac



  • I'm trying to compile a project with Qt Creator on Mac 10.11 El Capitan. Here is the content of the .pro file:

    QT += widgets
     
    HEADERS += \
        //quelques fichiers
     
    SOURCES += \
        //quelques fichiers
     
    INCLUDEPATH += "/Applications/Xcode.app/irrlicht-1.8.4/include"
     
    LIBS += -L"/Applications/Xcode.app/irrlicht-1.8.4/lib/MacOSX" -lIrrlicht
    

    The problem is that I get the error "symbol(s) not found for architecture x86_64" when I try to compile. I also get a lot of warnings about the Irrlicht library that my project uses. I've compiled the libIrrlicht.a file with XCode 7.3.1.

    alt text

    I'm new to Mac and have no idea what I'm doing wrong. What should I do?


  • Lifetime Qt Champion

    Hi,

    You shoud try to check the option used to build Irrlicht and whether it's a 32bit built library.


  • Moderators

    @Donald-Duck Can you show the whole build log?



  • @SGaist How do I do that? I compiled Irrlicht with XCode and since I'm a beginner to both Mac and XCode I have no idea how to do that.



  • @jsulm It won't let me post the build log because it's too long, but you can see it here.


  • Lifetime Qt Champion

    From what I can see you must add to the LIBS variable the framework that Irrlicht requires like Core Foundation and the other concerned by the missing symbols messages.



  • @SGaist How can I find out what framework that is?


  • Lifetime Qt Champion

    You can search the missing symbols on the Apple developer website or google you'll get the matching framework there.

    Or take a look at the Irrlicht project files.



  • @SGaist Thanks, I managed to get it to link almost all those symbols by adding the frameworks CoreFoundation, CoreGraphics and AppKit. But there are three that are still not working: std::_Rb_tree_decrement(std::_Rb_tree_node_base*), std::_Rb_tree_increment(std::_Rb_tree_node_base*) and std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&). I searched on Google for those but didn't find anything. What framework should I add to get those to work?


  • Lifetime Qt Champion

    Can you check what standard library Irrlicht uses ? Libc++ or libstdc++ ?



  • @SGaist I tried libstdc++ and then those three symbols worked but there were a lot of others that stopped working. How can I use both libc++ and libstdc++ in the same project?


  • Lifetime Qt Champion

    I'd rather go with building Irrlicht with libc++



  • @SGaist I added the following code in the .pro file and it compiled but it crashed at runtime:

    LIBS += -framework CoreFoundation
    LIBS += -framework CoreGraphics
    LIBS += -framework AppKit
    LIBS += -stdlib=libstdc++
    LIBS += -lc++
    

    This is what I got in the terminal when running it:

    Last login: Mon May 15 12:57:25 on ttys000
    /Users/donaldduck/Documents/build-untitled/Mac/untitled.app/Contents/MacOS/untitled ; exit;
    donalds-iMac:~ donaldduck$ /Users/donaldduck/Documents/build-untitled/Mac/untitled.app/Contents/MacOS/untitled ; exit;
    Irrlicht Engine version 1.8.4
    Darwin Kernel Version 15.6.0: Thu Jun 23 18:25:34 PDT 2016; root:xnu-3248.60.10~1/RELEASE_X86_64
    No doublebuffering available.
    Segmentation fault: 11
    logout
    Saving session...
    ...copying shared history...
    ...saving history...truncating history files...
    ...completed.
    
    [Process completed]
    
    

  • Lifetime Qt Champion

    You should run that through your debugger to see where exactly it's crashing.



  • @SGaist According to the debugger, the thing that's crashing is const core::position2di& curr = ((CCursorControl *)CursorControl)->getPosition(); at line 1289 in the file CIrrDeviceMacOSX.mm. The part of my own code that calls this is the function irr::createDeviceEx, which is an Irrlicht function that I use in my code. Here is the complete code of the function that crashes (I added a comment at the line that crashes):

    void CIrrDeviceMacOSX::storeMouseLocation()
    {
    	int x,y;
    
    	if (Window != NULL)
    	{
    		NSPoint	p;
    		p = [NSEvent mouseLocation];
    		p = [Window convertScreenToBase:p];
    		x = (int)p.x;
    		y = DeviceHeight - (int)p.y;
    	}
    	else
    	{
    		CGEventRef ourEvent = CGEventCreate(NULL);
    		CGPoint point = CGEventGetLocation(ourEvent);
    		CFRelease(ourEvent);
    
    		x = (int)point.x;
    		y = (int)point.y;
    
    		const core::position2di& curr = ((CCursorControl *)CursorControl)->getPosition();    //This is the line that crashes
    		if (curr.X != x || curr.Y != y)
    		{
    			// In fullscreen mode, events are not sent regularly so rely on polling
    			irr::SEvent ievent;
    			ievent.EventType = irr::EET_MOUSE_INPUT_EVENT;
    			ievent.MouseInput.Event = irr::EMIE_MOUSE_MOVED;
    			ievent.MouseInput.X = x;
    			ievent.MouseInput.Y = y;
    			postEventFromUser(ievent);
    		}
    	}
    
    	((CCursorControl *)CursorControl)->updateInternalCursorPosition(x,y);
    }
    

  • Moderators

    @Donald-Duck Most probably CursorControl is null pointer or dangling pointer. But I don't know why. Maybe you're doing something wrong in your code?



  • @jsulm That's not my code, it's Irrlicht's code. Irrlicht is a library that I'm using. I don't think there is anything wrong in my own code since it compiles and runs just fine on Windows and Linux.


  • Lifetime Qt Champion

    Hence my suggestion to re-build Irrlicht against the same C++ library as Qt.


  • Moderators

    @Donald-Duck said in "symbol(s) not found for architecture x86_64" error when compiling a Qt project on Mac:

    I don't think there is anything wrong in my own code since it compiles and runs just fine on Windows and Linux

    From my own experience I know that such assumptions are often wrong :-)
    But you should follow what @SGaist suggested.



  • @SGaist I tried rebuilding libIrrlicht.a with libc++ and without adding LIBS += -stdlib=libc++ and LIBS += -lc++ to my .pro file and it compiled and crashed just like first. It crashed at exactly the same place with exactly the same error.



  • @jsulm I tested to see if the problem was in my code or in Irrlicht by copy-pasting a code from an Irrlicht tutorial that I know is correct into a new project and it crashed just like in my project. So the problem isn't in my code but in the Irrlicht library.


  • Lifetime Qt Champion

    To be sure we're on the same page, you are calling irr::createDeviceEx and this crashes, right ?



  • @SGaist Yes.


  • Lifetime Qt Champion

    Since you are building Irrlicht anyway, I'd add some checks for CursorControl to see whether the pointer is null or just invalid.



  • @SGaist I checked and the pointer is null.


  • Lifetime Qt Champion

    As a quick workaround to be able to run your application, add an if around the code using that variable.

    The more involved method would be to find why it's null.



  • @SGaist said in "symbol(s) not found for architecture x86_64" error when compiling a Qt project on Mac:

    The more involved method would be to find why it's null.

    I've posted a question on the Irrlicht forum to find out why it's null: http://irrlicht.sourceforge.net/forum/viewtopic.php?f=7&t=51856&p=301630


Log in to reply