Compile generate 0 byte files on OS X



  • Hello everybody,

    I am working on a project that is a little bit hard for me because I don't have an extensive knowledge of Mac OS.

    I have a project that works on Windows and I have to compile it on Mac OS, with Qt.

    The problem is when I build the project, it generates me only empty files : .dylib .o .cpp and .h

    am I missing something like a special command in the .pro file ?

    Here is one .pro (others are nearly identical) :

    #-------------------------------------------------
    #
    # Project created by QtCreator 2016-04-18T21:12:51
    #
    #-------------------------------------------------
    
    QT       += widgets
    
    TARGET = MdDimension
    TEMPLATE = lib
    
    DEFINES += MDDIMENSION_LIBRARY \
    _TOOLKIT_IN_DLL_ \
    
    INCLUDEPATH += ../MdCore \
            ../MdWidgets \
            ../include \
            ../include/teigha \
            ../include/Extensions/ExServices \
            ./GUI \
    
    release {
    DESTDIR = ../release
    }
    
    debug {
    DESTDIR = ../debug
    }
    
    SOURCES += mddimensionmodule.cpp \
        widgets/mddimstylecombo.cpp \
        GUI/mddimstyletoolbar.cpp
    
    HEADERS += mddimensionmodule.h\
        widgets/mddimstylecombo.h \
        GUI/mddimstyletoolbar.h \
        mddimensiondefs.h
    
    
    win32{
        CONFIG(debug, debug|release) {
            LIBS += -L$$PWD/../build/debug -lMdCore \
                    -L$$PWD/../build/debug -lMdWidgets \
                    -L$$PWD/../build/debug -lMdModels \
    
            # Librairies ODA
            LIBS += -L$$PWD/../lib/win32/debug -lTD_Db \
             -L$$PWD/../lib/win32/debug -lTD_Root \
             -L$$PWD/../lib/win32/debug -lTD_Alloc \
             -L$$PWD/../lib/win32/debug -lTD_DbRoot \
            -ladvapi32
    
            DEPENDPATH += $$PWD/../lib/win32/debug
        }
        CONFIG(release, debug|release) {
            LIBS += -L$$PWD/../build/release -lMdCore \
                    -L$$PWD/../build/release -lMdWidgets \
                    -L$$PWD/../build/release -lMdModels \
    
            # Librairies ODA
            LIBS += -L$$PWD/../lib/win32/release -lTD_Db \
             -L$$PWD/../lib/win32/release -lTD_Root \
             -L$$PWD/../lib/win32/release -lTD_Alloc \
             -L$$PWD/../lib/win32/release/ -lTD_DbRoot \
            -ladvapi32
    
            DEPENDPATH += $$PWD/../lib/win32/release
        }
    }
    
    
    unix{
        CONFIG(debug, debug|release) {
            LIBS += -L$$PWD/../build/debug -lMdCore \
                    -L$$PWD/../build/debug -lMdWidgets \
                    -L$$PWD/../build/debug -lMdModels \
    
            # Librairies ODA
            LIBS += -L$$PWD/../lib/unix/debug -lTD_Db \
             -L$$PWD/../lib/unix/debug -lTD_Root \
             -L$$PWD/../lib/unix/debug -lTD_Alloc \
             -L$$PWD/../lib/unix/debug/ -lTD_DbRoot \
    
            DEPENDPATH += $$PWD/../lib/unix/debug
        }
        CONFIG(release, debug|release) {
            LIBS += -L$$PWD/../build/release -lMdCore \
                    -L$$PWD/../build/release -lMdWidgets \
                    -L$$PWD/../build/release -lMdModels \
    
            # Librairies ODA
            LIBS += -L$$PWD/../lib/unix/release -lTD_Db \
             -L$$PWD/../lib/unix/release -lTD_Root \
             -L$$PWD/../lib/unix/release -lTD_Alloc \
             -L$$PWD/../lib/unix/release -lTD_DbRoot \
    
            DEPENDPATH += $$PWD/../lib/unix/release
        }
    }
    
    unix {
        target.path = /usr/lib
        INSTALLS += target
    }
    
    
    
    TARGET_EXT = _4.02_14.mrx
    
    RESOURCES += \
        mddimension.qrc
    

    I don't have any error or warning when I build a library.

    So if anyone have a clue or an explanation to the problem, I will be interested :)

    Thank you !


  • Moderators

    How do you build on MacOS? Which Qt version did you install and how?
    Can you share the compiler/linker output?



  • hi jisulm, thanks for your response, to build on Mac OS I right click on my library and select "compile" or clean - qmake - compile when I change the .pro. I'm using Qt 5.7 on QtCreator 4.0.2.

    Here is the output :

    Reading makefiles...
    Reading makefile `Makefile'...
    Updating makefiles....
     Considering target file `Makefile'.
       Considering target file `../Myproject.pro'.
        Looking for an implicit rule for `../Myproject.pro'.
        Trying pattern rule with stem `Myproject.pro'.
        Trying implicit prerequisite `../Myproject.pro.o'.
        Trying pattern rule with stem `Myproject.pro'.
        Trying implicit prerequisite `../Myproject.pro.c'.
        Trying pattern rule with stem `Myproject.pro'.
        Trying implicit prerequisite `../Mediacad2.pro.cc'.
        Trying pattern rule with stem `Myproject.pro'.
        Trying implicit prerequisite `../Myproject.pro.C'.
        Trying pattern rule with stem `Myproject.pro'.
        Trying implicit prerequisite `../Myproject.pro.cpp'.
        Trying pattern rule with stem `Myproject.pro'.
    
    ... 
    
    Looking for a rule with intermediate file `../../../../Qt/5.7/clang_64/mkspecs/modules/qt_lib_qmltest_private.pri.r'.
           Avoiding implicit rule recursion.
           Avoiding implicit rule recursion.
           Avoiding implicit rule recursion.
           Trying pattern rule with stem `qt_lib_qmltest_private.pri'.
           Rejecting impossible implicit prerequisite `../../../../Qt/5.7/clang_64/mkspecs/modules/qt_lib_qmltest_private.pri.l'.
           Trying pattern rule with stem `qt_lib_qmltest_private.pri.r'.
           Trying implicit prerequisite `../../../../Qt/5.7/clang_64/mkspecs/modules/qt_lib_qmltest_private.pri.r,v'.
           Trying pattern rule with stem `qt_lib_qmltest_private.pri.r'.
           Trying implicit prerequisite `../../../../Qt/5.7/clang_64/mkspecs/modules/RCS/qt_lib_qmltest_private.pri.r,v'.
           Trying pattern rule with stem `qt_lib_qmltest_private.pri.r'.
           Trying implicit prerequisite `../../../../Qt/5.7/clang_64/mkspecs/modules/RCS/qt_lib_qmltest_private.pri.r'.
           Trying pattern rule with stem `qt_lib_qmltest_private.pri.r'.
           Trying implicit prerequisite `../../../../Qt/5.7/clang_64/mkspecs/modules/s.qt_lib_qmltest_private.pri.r'.
           Trying pattern rule with stem `qt_lib_qmltest_private.pri.r'.
           Trying implicit prerequisite `../../../../Qt/5.7/clang_64/mkspecs/modules/SCCS/s.qt_lib_qmltest_private.pri.r'.
         Trying pattern rule with stem `qt_lib_qmltest_private.pri'.
         Rejecting impossible implicit prerequisite `../../../../Qt/5.7/clang_64/mkspecs/modules/qt_lib_qmltest_private.pri.F'.
         Trying pattern rule with stem `qt_lib_qmltest_private.pri'.
         Trying implicit prerequisite `../../../../Qt/5.7/clang_64/mkspecs/modules/qt_lib_qmltest_private.pri.m'.
         Looking for a rule with intermediate file `../../../../Qt/5.7/clang_64/mkspecs/modules/qt_lib_qmltest_private.pri.m'.
          Avoiding implicit rule recursion.
          Avoiding implicit rule recursion.
    Skip doing additional output
    

    And now I have 4 warnings :

    /build/Makefile:1959: avertissement : overriding commands for target `install_target'
    /build/Makefile:1944: avertissement : ignoring old commands for target build/Makefile:1959: avertissement : overriding commands for target `uninstall_target'
    /build/Makefile:1944: avertissement : ignoring old commands for target `uninstall_target'
    

  • Lifetime Qt Champion

    Hi,

    Unless I misunderstood, your lib project is part of a bigger project ? If so, what is it ?

    One a side note, it seems you are having plenty of unneeded \ in your .pro file. You should clean them up



  • Hi SGaist,

    yes, here it what the project looks like :
    http://hpics.li/d8bb2ec
    The main project uses every libs. And all of them generate empty files


  • Lifetime Qt Champion

    Can you show the content of medicad2.pro ?



  • here it is :

    TEMPLATE = subdirs
    
    SUBDIRS += \
        MdCore \
        MdWidgets \
        MediaCad \
        MdModels \
        QtOpenGL \
        MdDimension \
        MdProfile \
        MdDrawing2d \
        MdPrint \
        MddwgParameters
    
     # where to find the sub projects - give the folders
    MdCore.subdir = MdCore
    MdWidgets.subdir  = MdWidgets
    MediaCad.subdir  = MediaCad
    MdModels.subdir  = MdModels
    MdDimension.subdir  = MdDimension
    QtOpenGL.subdir  = QtOpenGL
    MdProfile.subdir = MdProfile
    MdDrawing2d.subdir = MdDrawing2d
    MdPrint.subdir = MdPrint
    MddwgParameters.subdir = MddwgParameters
    
     # what subproject depends on others
    MdWidgets.depends = MdCore
    MediaCad.depends = MdCore MdWidgets
    MdModels.depends = MdCore
    MdDimension.depends = MdCore MdWidgets
    MdProfile.depends = MdCore MdWidgets MdModels
    MdDrawing2d.depends = MdCore
    MdPrint.depends = MdCore
    MddwgParameters.depends = MdCore MdWidgets
    
    

  • Lifetime Qt Champion

    Can you reproduce that with a minimal project ?

    Note there's one thing that I find a bit strange with your current project. For MdDimension, it looks like you are picking pieces from other folders and rebuild them there rather than having the common classes themselves in a library that would link against.



  • Yes, I have a basic project (just a main.cpp and a mainwindow), using the ODA library and I have the same result. Maybe the error comes from this library ?


  • Lifetime Qt Champion

    What does that library look like ?



  • I don't know what you mean by saying that but I hope my answer is what you expect.
    ODA is a library to manage .dwg and .dgn files. It is composed with a folder "lib" where are placed a lot of .a, a folder "bin" with some unix executable, a folder "include" with some headers. I copied / pasted them into different folder and linked them to my application.
    Here is the what the full library looks like :
    http://hpics.li/58b8b54



  • Here I am again with some news, I have successfully built a basic project that includes ODA library, so I did the same operation with the same include files on the real project but it still generate me empty files.
    I have compared both .pro file and I have notice that may be the source of the error :

    target.path = /usr/lib
    INSTALLS += target
    

    It's the only thing that is different between the project that works and the real project. I have tried to change the target but nothing happens, am I missing something ?


  • Lifetime Qt Champion

    Try change target for some other name. my_target should do it.



  • I tried this too but it doesn't change anything. Maybe a last idea, at the very beginning, I had an error :
    Undefined symbols for architecture x86_64
    The solution I find was to add -stdlib=libstdc++ to qmake. Maybe there was another solution ?



  • I just realizze that I spoke too fast, my other project was working but it was to generate a .app not a lib...
    I retried to create a lib step by step :
    -create a lib project -> works
    -add include path to ODA library to the project -> works
    -use a variable of ODA -> error above
    -add libstdc++ to qmake -> generate empty files
    So the problem comes from either ODA or libstdc++, I will continue to search the solution


  • Lifetime Qt Champion

    Is ODA built against the old C++ library ?



  • I don't know, the package is named "Teigha_macOsX_x64_10.11" and the mac is in 64bit on OS X 10.11. I will ask in the ODA forum to know
    Edit : I can generate some files now ! I change qmake argument to CFLAGS="-arch x86_64" but at a certain point it generate me the error above.


  • Lifetime Qt Champion

    The best would be to ensure what were the parameters used to build that library. It's surprising if they don't use libc++.



  • I have made a test with the command "file" to know what kind of library is it, here are my results :

    a random lib in /usr/lib :

    Mach-0 universal binary with 2 architectures
    (for architecture x68_64): Mach-0 64-bit dynamically linked shared library x86_64
    (for architecture i386): Mach-0 dynamically linked shared library i386
    

    a lib from ODA :

    current ar archive random library
    

    I'm not sure of what it means, the library is not compatible with the Mac ?



  • @Amott

    I use that ODA library on OSX and I link it with the c library like this...

    LIBS += -lc++ \
    -lTD_Db \
    ... other ODA libs

    and it works fine.



  • @kenchan

    Thanks for your response ! I have tried again but I still have the same error. Which version of OSX, ODA and XCode are you using ?



  • I finally found the solution : I needed a line on the .pro :
    QMAKE_LFLAGS += -framework CoreFoundation


  • Lifetime Qt Champion

    Strange… You should have had undefined symbols errors…

    In any case it should rather be: LIBS += -framework CoreFoundation



  • it works too, I will replace this variable. It strange but it works, after 3 weeks, I'm so happy that something works taht I won't search why it doesn't make me an error !


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.