PDA

View Full Version : problem creating a qjson0.lib



Qg90
15th March 2014, 22:02
Hi, i am trying to generate a lib from this project https://github.com/flavio/qjson with Qt5.2.1 and msvc2010 compiler.

Can anyone assist? I build the project without problems but there is no qjson0.lib, i need it for this project to work. https://code.google.com/p/qt-google-maps/

This is the developers site. (http://qjson.sourceforge.net/)

ChrisW67
16th March 2014, 03:46
That's probably because it is called qjson.lib at a guess.

Qg90
16th March 2014, 03:51
This is inside the pro file.

win32-g++ {
LIBS += ../qjson/build/lib/qjson0.dll
}

win32-msvc* {
LIBS += ../qjson/build/lib/qjson0.lib
}

ChrisW67
16th March 2014, 06:37
So? What does the QJson project actually build?

Qg90
16th March 2014, 11:17
It's supposed to build a library. I'm using the CLI way found here (http://qjson.sourceforge.net/build/).

at the "mingw32-make" command i get this error.

C:\Users\George\Desktop\qjson\build>mingw32-make
Scanning dependencies of target qjson_automoc
[ 11%] Automoc for target qjson
Generating moc_parserrunnable.cpp
Generating moc_qobjecthelper.cpp
C:/Users/George/Desktop/qjson/src/qobjecthelper.h(0): Note: No relevant classes
found. No output generated.
Generating moc_serializerrunnable.cpp
[ 11%] Built target qjson_automoc
Scanning dependencies of target qjson
[ 22%] Building CXX object src/CMakeFiles/qjson.dir/parser.cpp.obj
[ 33%] Building CXX object src/CMakeFiles/qjson.dir/qobjecthelper.cpp.obj
[ 44%] Building CXX object src/CMakeFiles/qjson.dir/json_scanner.cpp.obj
[ 55%] Building CXX object src/CMakeFiles/qjson.dir/json_parser.cc.obj
[ 66%] Building CXX object src/CMakeFiles/qjson.dir/parserrunnable.cpp.obj
[ 77%] Building CXX object src/CMakeFiles/qjson.dir/serializer.cpp.obj
[ 88%] Building CXX object src/CMakeFiles/qjson.dir/serializerrunnable.cpp.obj
[100%] Building CXX object src/CMakeFiles/qjson.dir/qjson_automoc.cpp.obj
Linking CXX shared library libqjson.dll
CMakeFiles\qjson.dir/objects.a(parser.cpp.obj):parser.cpp:(.text+0x4b): undefine
d reference to `_imp___ZN8QVariantD1Ev'
CMakeFiles\qjson.dir/objects.a(parser.cpp.obj):parser.cpp:(.text+0xa8): undefine
d reference to `_imp___ZN8QVariantD1Ev'
CMakeFiles\qjson.dir/objects.a(parser.cpp.obj):parser.cpp:(.text+0xc8): undefine
d reference to `_imp___ZN8QVariantD1Ev'
CMakeFiles\qjson.dir/objects.a(parser.cpp.obj):parser.cpp:(.text+0x10f) : undefin
ed reference to `_imp___ZN7QStringaSERKS_'
CMakeFiles\qjson.dir/objects.a(parser.cpp.obj):parser.cpp:(.text+0x213) : undefin
ed reference to `_imp___ZNK9QIODevice6isOpenEv'
CMakeFiles\qjson.dir/objects.a(parser.cpp.obj):parser.cpp:(.text+0x298) : undefin
ed reference to `_imp___ZNK14QMessageLogger8criticalEPKcz'
CMakeFiles\qjson.dir/objects.a(parser.cpp.obj):parser.cpp:(.text+0x2b6) : undefin
ed reference to `_imp___ZNK9QIODevice10isReadableEv'
CMakeFiles\qjson.dir/objects.a(parser.cpp.obj):parser.cpp:(.text+0x302) : undefin
ed reference to `_imp___ZNK14QMessageLogger8criticalEPKcz'
CMakeFiles\qjson.dir/objects.a(parser.cpp.obj):parser.cpp:(.text+0x49d) : undefin
ed reference to `_imp___ZN8QVariantC1ERKS_'
CMakeFiles\qjson.dir/objects.a(parser.cpp.obj):parser.cpp:(.text+0x51d) : undefin
ed reference to `_imp___ZN7QBufferC1EP7QObject'
CMakeFiles\qjson.dir/objects.a(parser.cpp.obj):parser.cpp:(.text+0x546) : undefin
ed reference to `_imp___ZN7QBuffer4openE6QFlagsIN9QIODevice12OpenM odeFlagEE'
CMakeFiles\qjson.dir/objects.a(parser.cpp.obj):parser.cpp:(.text+0x577) : undefin
ed reference to `_imp___ZN7QBuffer4seekEx'
CMakeFiles\qjson.dir/objects.a(parser.cpp.obj):parser.cpp:(.text+0x5a7) : undefin
ed reference to `_imp___ZN7QBufferD1Ev'
CMakeFiles\qjson.dir/objects.a(parser.cpp.obj):parser.cpp:(.text+0x5bb) : undefin
ed reference to `_imp___ZN7QBufferD1Ev'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: CMakeFiles
\qjson.dir/objects.a(parser.cpp.obj): bad reloc address 0x10 in section `.text$_
ZN14QMessageLoggerC1EPKciS1_[__ZN14QMessageLoggerC1EPKciS1_]'
collect2.exe: error: ld returned 1 exit status
src\CMakeFiles\qjson.dir\build.make:272: recipe for target 'src/libqjson.dll' fa
iled
mingw32-make[2]: *** [src/libqjson.dll] Error 1
CMakeFiles\Makefile2:109: recipe for target 'src/CMakeFiles/qjson.dir/all' faile
d
mingw32-make[1]: *** [src/CMakeFiles/qjson.dir/all] Error 2
Makefile:115: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

ChrisW67
16th March 2014, 21:23
So you are not using MSVC 2010, you are trying to build with MingW. QJson is failing to link because it looks like CMake has not correctly located Qt, or has created an incorrect linker command.

If it had compiled and linked (it has not) then the resulting library file is libqjson.dll and the reference from the other project should not include the zero.


LIBS += -Lc:/path/to/qjson -lqjson

Qg90
17th March 2014, 00:11
Correct i am using the commands on the CLI example. I installed the MinGW compiler outside the Qt and i used it. This is the output from the "cmake -G "MinGW-make" .." command.

C:\Users\George\Desktop\qjson\build>cmake -G "MinGW Makefiles" ..
-- The C compiler identification is GNU 4.8.1
-- The CXX compiler identification is GNU 4.8.1
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
Qt5 found
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/George/Desktop/qjson/build

Also i used cmake gui and this is the output:

The C compiler identification is MSVC 16.0.40219.1
The CXX compiler identification is MSVC 16.0.40219.1
Check for working C compiler using: Visual Studio 10
Check for working C compiler using: Visual Studio 10 -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler using: Visual Studio 10
Check for working CXX compiler using: Visual Studio 10 -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Qt5 found
Configuring done
Generating done

Now on the build file i have vc projects.

Added after 53 minutes:

I opened the msvc 2010 as an administrator and built the solution and i got a C:\Program Files (x86)\qjson folder with a qjson.lib include. I added the lib but my app crashes before it starts.
I added the LIBS += -Lc:/path/to/qjson -lqjson but i get the following error


:-1: error: LNK1104: cannot open file 'qjson.lib'

ChrisW67
17th March 2014, 23:04
Please tell me you did not literally put:


LIBS += -Lc:/path/to/qjson -lqjson

in your PRO file. Given the path you specified:


LIBS += -L"C:\Program Files (x86)\qjson" -lqjson

Qg90
18th March 2014, 22:46
Of course i didn't put just LIBS += -Lc:/path/to/qjson -lqjson i specified the path to this LIBS += ../qjson/qjson.lib. The build was completed without errors but when i run the program i get this error:

Starting C:\Users\George\Desktop\build-qt-google-maps-Desktop_Qt_5_2_1_MSVC2010_32bit_OpenGL2-Debug\debug\qtmaps.exe...
The program has unexpectedly finished.
C:\Users\George\Desktop\build-qt-google-maps-Desktop_Qt_5_2_1_MSVC2010_32bit_OpenGL2-Debug\debug\qtmaps.exe crashed

Also i used your line in the PRO file but i didn't built.

:-1: error: LNK1104: cannot open file 'qjson.lib'

ChrisW67
19th March 2014, 05:49
You have two projects.

The first is one that builds QJSon. You should not need to modfiy the project to build QJson at all.
I am assuming you have successfuly built QJSon and obtained a qjosn link library, and a matching DLL if t QJSon was built for dynamic linking.

The other is the qtmaps thingy that consumes QJson. It is the second project that the LIBS line is for, and only if the one that is there already is incorrect. The path following -L tells the linker a directory to search when look for the link library specified by the -l option. The paths and library name must be correct or you get the linker complaining about missing dependencies. If you use a relative path then it is relative to wherever the build process happens to have its current directory at link time: this may not be relative to the source and may not be where you think it is.

If you have successfully built qtmaps (it really is not clear) then none of the preceding stuff matters any more.

If QJSon was built as a dynamic library then at run time the qtmaps program must be able to find the QJson DLL that matches the link library. The DLL must either be in the same directory as the qtmaps.exe or on the PATH the qtmaps.exe is run with.

Qg90
19th March 2014, 08:05
If QJSon was built as a dynamic library then at run time the qtmaps program must be able to find the QJson DLL that matches the link library. The DLL must either be in the same directory as the qtmaps.exe or on the PATH the qtmaps.exe is run with.

You sir are my hero!!!!!!! This line did the trick. I put the qjson.dll on the same directory as the qtmaps.exe and it run!!!!!!