Menu

Static Build Possible?

Help
Anonymous
2010-06-23
2013-04-06
  • Anonymous

    Anonymous - 2010-06-23

    Thanks for this great library.
    I was wondering if it is possible to perform a static build of pythonqt lib? If so, what parameters do I need to change in the build process?
    Thanks

     
  • Florian Link

    Florian Link - 2010-06-23

    Never tried, you probably just use the "staticlib" instead of the "dll" keyword in the CONFIG line of PythonQt.

    regards,
    Florian

     
  • Anonymous

    Anonymous - 2010-06-24

    So I was able to successfully compile static PythonQt lib. But I get these errors when using the lib to compile examples…

    1>------ Build started: Project: PyScriptingConsole_d, Configuration: Release Win32 ------
    1>RCC PyScriptingConsole.qrc
    1>MOC PyExampleObject.h
    1>Compiling...
    1>qrc_PyScriptingConsole.cpp
    1>moc_PyExampleObject.cpp
    1>main.cpp
    1>PyExampleObject.cpp
    1>Generating Code...
    1>Linking...
    1>PyExampleObject.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall PythonQtObjectPtr::~PythonQtObjectPtr(void)" (__imp_??1PythonQtObjectPtr@@QAE@XZ) referenced in function "public: struct _object * __thiscall PyExampleObject::getMainModule(void)" (?getMainModule@PyExampleObject@@QAEPAU_object@@XZ)
    1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall PythonQtObjectPtr::~PythonQtObjectPtr(void)" (__imp_??1PythonQtObjectPtr@@QAE@XZ)
    1>PyExampleObject.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class PythonQtObjectPtr __thiscall PythonQt::getMainModule(void)" (__imp_?getMainModule@PythonQt@@QAE?AVPythonQtObjectPtr@@XZ) referenced in function "public: struct _object * __thiscall PyExampleObject::getMainModule(void)" (?getMainModule@PyExampleObject@@QAEPAU_object@@XZ)
    1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class PythonQtObjectPtr __thiscall PythonQt::getMainModule(void)" (__imp_?getMainModule@PythonQt@@QAE?AVPythonQtObjectPtr@@XZ)
    1>PyExampleObject.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) private: static class PythonQt * PythonQt::_self" (__imp_?_self@PythonQt@@0PAV1@A) referenced in function "public: struct _object * __thiscall PyExampleObject::getMainModule(void)" (?getMainModule@PyExampleObject@@QAEPAU_object@@XZ)
    1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: static class PythonQt * PythonQt::_self" (__imp_?_self@PythonQt@@0PAV1@A)
    1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall PythonQtScriptingConsole::~PythonQtScriptingConsole(void)" (__imp_??1PythonQtScriptingConsole@@UAE@XZ) referenced in function _main
    1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall PythonQtObjectPtr::evalFile(class QString const &)" (__imp_?evalFile@PythonQtObjectPtr@@QAEXABVQString@@@Z) referenced in function _main
    1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall PythonQtObjectPtr::addObject(class QString const &,class QObject *)" (__imp_?addObject@PythonQtObjectPtr@@QAEXABVQString@@PAVQObject@@@Z) referenced in function _main
    1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall PythonQtScriptingConsole::PythonQtScriptingConsole(class QWidget *,class PythonQtObjectPtr const &,class QFlags<enum Qt::WindowType>)" (__imp_??0PythonQtScriptingConsole@@QAE@PAVQWidget@@ABVPythonQtObjectPtr@@V?$QFlags@W4WindowType@Qt@@@@@Z) referenced in function _main
    1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl PythonQt_QtAll::init(void)" (__imp_?init@PythonQt_QtAll@@YAXXZ) referenced in function _main
    1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static void __cdecl PythonQt::init(int,class QByteArray const &)" (__imp_?init@PythonQt@@SAXHABVQByteArray@@@Z) referenced in function _main
    1>..\..\lib\PyScriptingConsole.exe : fatal error LNK1120: 9 unresolved externals
    1>Build log was saved at "file://c:\Users\Siddharth Garg\Desktop\PythonQt2.0.1\examples\PyScriptingConsole\release\BuildLog.htm"
    1>PyScriptingConsole_d - 13 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    

    From my limited understanding of dynamic libs… it seems that the compiler expects the functions and objects to be dll linked in the lib rather than static, since the classes and methods were defined as such.

    Is there a way around that? What I hoped to achieve was a single static PythonQt.lib (or PythonQt_All.lib) such that my exe would only require the python26.dll upon execution.

    Thanks

     
  • Florian Link

    Florian Link - 2010-06-25

    You need to patch PythonQtSystem.h
    and always define PYTHONQT_EXPORT as empty:

    #define PYTHONQT_EXPORT

    otherwise the VC compiler will expect that the symbols are in an external DLL.

     
  • Maxim Chertov

    Maxim Chertov - 2010-12-03

    I compiled replacing code in PythonQtSystem.h

    #ifndef _PYTHONQTSYSTEM_
    #define _PYTHONQTSYSTEM_
    /*
     * Copyright (C) 2010....
        .....
     */
    #ifdef WIN32
      #ifdef PYTHONQT_EXPORTS
        #ifdef PYTHONQT_STATIC_LIB
          #define PYTHONQT_EXPORT
        #else
          #define PYTHONQT_EXPORT __declspec(dllexport)
        #endif
      #else
        #ifdef PYTHONQT_STATIC_LIB
          #define PYTHONQT_EXPORT
        #else
          #define PYTHONQT_EXPORT __declspec(dllimport)
        #endif
      #endif
    #else
      #define PYTHONQT_EXPORT
    #endif
    

    And define PYTHONQT_STATIC_LIB in PythonQt library and application

     
  • Maxim Chertov

    Maxim Chertov - 2010-12-03

    #endif missing…

    Full code PythonQtSystem.h

    #ifndef _PYTHONQTSYSTEM_
    #define _PYTHONQTSYSTEM_
    /*
     *  Copyright (C)....
     */
    #ifdef WIN32
      #ifdef PYTHONQT_EXPORTS
        #ifdef PYTHONQT_STATIC_LIB
          #define PYTHONQT_EXPORT
        #else
          #define PYTHONQT_EXPORT __declspec(dllexport)
        #endif
      #else
        #ifdef PYTHONQT_STATIC_LIB
          #define PYTHONQT_EXPORT
        #else
          #define PYTHONQT_EXPORT __declspec(dllimport)
        #endif
      #endif
    #else
      #define PYTHONQT_EXPORT
    #endif
    #endif
    
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.