This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Setting up Marble for Visual Studio

Tags: None
(comma "," separated)
nyshadham
Registered Member
Posts
1
Karma
0

Setting up Marble for Visual Studio

Thu May 02, 2013 3:40 pm
Hi All,

I have Qt setup for Visual Studio already, I am trying to integrate marble as well. I am not using QT creator.. I am using VS2010.

I followed the instructions from here -> http://techbase.kde.org/Projects/Marble ... sCompiling

After I complied Marble for VS using GIT. I used cmake to build binaries.

Then finally build the solution from VS. My installation folder has marblewidget.dll instead of libmarblewidget.dll.

I made sure I had QTOnly checked (cmake GUI). I tried couple of times and I always have marblewidget.dll only. What am I missing?

Next, I still proceeded in copy pasting marblewidget.dll and /data near QT desinger.exe and I was able to view the marble widget from my QT Desinger. However when I am using it , I get a black screen and don't see the globe. What is I am doing wrong, is it not working since I am using marblewidget.dll instead of libmarblewidget.dll?

Please point where I am wrong?

One more question, If not marble is there anyway, I can use an Openstreetmap with QT . I want to build an application using QT and OSM.

Thank You
Harsha
User avatar
artembogdanov
Registered Member
Posts
11
Karma
0
Here are the steps which works ok for me (VS2008), maybe this can help you...

0. Download and install prerequisites (except Visual Studio, which is already downloaded and installed, I guess):
a) Qt (I download this package);
b) CMake (here);
c) Git tools and GUI client (I am using TortoiseGit).

1. Download / update sources from git (for example, with TortoiseGit).

2. Copy downloaded sources to some working dir %WORKSRC%, for example "D:\Works\Marble" (without quotes).

3. Run CMake GUI.
a) press the "Browse Source..." button and select %WORKSRC% dir;
b) press the "Browse Build..." button and select/create %WORKBLD% dir, for example "D:\Works\Marble\build.win32" (without quotes);
c) press the "Configure" button and select your compiler (I select Visual Studio 9 2008);
d) after generating process is done, you will see an error message - it's ok for this step.

4. Change some settings and reconfigure:
a) expand "Ungrouped Entries" group in variables list and make sure that only the QTONLY checkbox is set (I always deselect TILES_AT_COMPILETIME);
b) expand "CMAKE" group in variables list and set CMAKE_USE_RELATIVE_PATHS checkbox;
c) again, press the "Configure" button.

5. Make last settings change:
a) expand "WITH" group in variables list and make sure that all checkboxes are clear; optionally, you can set checkboxes "WITH_Phonon" (for audio support?) and/or "WITH_libshp" (needed for shapefiles plugin);
b) if you selected "WITH_libshp", expand "LIBSHP" group in variables list and select shapelib source root dir for "LIBSHP_INCLUDE_DIR" and compiled shapelib static library file (shapelib.lib for me) for "LIBSHP_LIBRARIES";
c) expand "BUILD" group in variables list and make sure that all checkboxes are clear; optionally, you can leave "BUILD_TESTING" set;
d) at last, press the "Configure" button.

6. Press "Generate" button.

7. Go to %WORKBLD% dir and open "marble.sln" solution file with Visual Studio.

8. In solution browser, locate project named "marble-qt" and set it as a start project.

9. Compile solution. Make sure that marblewidget.dll and most of plugins are compiled ok.

10. Create two new text files in %WORKSRC% dir, "make_release.cmd" and "plugins_list.txt", with the following contents:

make_release.cmd
Code: Select all
@echo off

setlocal enableextensions enabledelayedexpansion
set BUILD_DIR=%~dp0build.win32
if "%1"=="" (
    set SOLUTION_CFG=release
) else (
    set SOLUTION_CFG=%1
)
if "%2"=="" (
    set PLUGINS_LIST=%~dp0plugins_list.txt
) else (
    set PLUGINS_LIST=%2
)
if "%3"=="" (
    set TARGET_DIR=%~d0\Marble\%SOLUTION_CFG%
) else (
    set TARGET_DIR=%3
)

echo BUILD_DIR  = %BUILD_DIR%
echo TARGET_DIR = %TARGET_DIR%

set REG_PARAMETER=defaultqtversion
for /f "usebackq tokens=3* delims= " %%a in (`reg query "hkcu\software\trolltech\versions" /v "%REG_PARAMETER%" 2^>nul ^|find /i "%REG_PARAMETER%"`) do (
    set QT_VERSION=%%a
)
set QT_MAJVER=%QT_VERSION:~0,1%

set REG_PARAMETER=installdir
for /f "usebackq tokens=3* delims= " %%a in (`reg query "hklm\software\trolltech\versions\%QT_VERSION%" /v "%REG_PARAMETER%" 2^>nul ^|find /i "%REG_PARAMETER%"`) do (
    set QT_DIR=%%a
)
if ""=="%QT_DIR%" (
    for /f "usebackq tokens=3* delims= " %%a in (`reg query "hkcu\software\trolltech\versions\%QT_VERSION%" /v "%REG_PARAMETER%" 2^>nul ^|find /i "%REG_PARAMETER%"`) do (
        set QT_DIR=%%a
    )
)

if ""=="%QT_DIR%" set QT_VERSION=
if ""=="%QT_VERSION%" (
    echo FATAL: QT not found. Exiting.
    pause
    goto :ENDOFSCRIPT
)

echo QT version %QT_VERSION% found installed in %QT_DIR%
if /i "%SOLUTION_CFG%" neq "debug" (
    set DBG_SUFFIX=
) else (
    set DBG_SUFFIX=d
)

rem move /y "%TARGET_DIR%" >nul 2>nul
if not exist "%TARGET_DIR%" md "%TARGET_DIR%" >nul
echo.
echo 1. Copying main application files...
copy /y "%BUILD_DIR%\src\%SOLUTION_CFG%\marble-qt.exe" "%TARGET_DIR%" >nul
copy /y "%BUILD_DIR%\src\lib\%SOLUTION_CFG%\*.dll" "%TARGET_DIR%\*.dll" >nul

set COPY_DIR=%QT_DIR%\bin
set CPYTO_DIR=%TARGET_DIR%
if not exist "%CPYTO_DIR%" md "%CPYTO_DIR%" >nul
echo.
echo 2. Copying Qt system dlls from %COPY_DIR%...
for /d %%a in (QtCore QtDeclarative QtDesigner QtGui QtNetwork QtOpenGL QtScript QtSql QtSvg QtWebKit QtXml QtXmlPatterns phonon) do (
    copy /y "%COPY_DIR%\%%a%DBG_SUFFIX%%QT_MAJVER%.dll" "%CPYTO_DIR%\" >nul
)

set COPY_DIR=%QT_DIR%\plugins\imageformats
set CPYTO_DIR=%TARGET_DIR%\plugins\imageformats
rem move /y "%CPYTO_DIR%" >nul 2>nul
if not exist "%CPYTO_DIR%" md "%CPYTO_DIR%" >nul
echo.
echo 3. Copying Qt plugin dlls from %COPY_DIR%...
for /d %%a in (qgif qico qjpeg qmng qsvg qtga qtiff) do (
    copy /y "%COPY_DIR%\%%a%DBG_SUFFIX%%QT_MAJVER%.dll" "%CPYTO_DIR%\" >nul
)
set COPY_DIR=%QT_DIR%\plugins\bearer
set CPYTO_DIR=%TARGET_DIR%\plugins\bearer
rem move /y "%CPYTO_DIR%" >nul 2>nul
if not exist "%CPYTO_DIR%" md "%CPYTO_DIR%" >nul
for /d %%a in (qgenericbearer qnativewifibearer) do (
    copy /y "%COPY_DIR%\%%a%DBG_SUFFIX%%QT_MAJVER%.dll" "%CPYTO_DIR%\" >nul
)

set COPY_DIR=%BUILD_DIR%\src\plugins
set CPYTO_DIR=%TARGET_DIR%\plugins
del /q /f "%CPYTO_DIR%\*.*" >nul
if not exist "%CPYTO_DIR%" md "%CPYTO_DIR%" >nul
echo.
echo 4. Copying application plugins from %COPY_DIR%...
for /f "usebackq eol=; delims=" %%a in (`type "%PLUGINS_LIST%"`) do (
    copy /y "%COPY_DIR%\%%a\%SOLUTION_CFG%\*.dll" "%CPYTO_DIR%\*.dll" >nul
)

set COPY_DIR=%~dp0data
set CPYTO_DIR=%TARGET_DIR%\data
rem move /y "%CPYTO_DIR%" >nul 2>nul
if not exist "%CPYTO_DIR%" md "%CPYTO_DIR%" >nul
echo.
echo 5. Copying additional application's data from %COPY_DIR%...
xcopy /y /e "%COPY_DIR%" "%CPYTO_DIR%" >nul


:ENDOFSCRIPT
endlocal

plugins_list.txt
Code: Select all
network\qnam
render\atmosphere
render\compass
render\crosshairs
render\graticule
render\mapscale
render\overviewmap
render\satellites
render\stars
render\navigation
runner\cache
runner\kml
runner\pnt
runner\shp


11. To install compiled Marble to specified location (installed application can be copied anywhere, also on a machine without Qt and/or Visual Studio) run make_release.cmd as follows:

Code: Select all
make_release.cmd %SOLUTION_CFG% %PLUGINS_LIST% %TARGET_DIR%

where %SOLUTION_CFG% is a compiled solution config - Debug, MinSizeRel, Release or RelWithDebInfo (Release by default),
%PLUGINS_LIST% is a nesessary plugins list file (plugins_list.txt by default),
%TARGET_DIR% is a target dir where to copy all files needed to run the application (default - "X:\Marble\%SOLUTION_CFG%" folder, where X - drive where %WORKSRC% is located).

For example:
Code: Select all
make_release.cmd

Code: Select all
make_release.cmd debug plugins_list.txt "C:\Program Files\Marble"

Code: Select all
make_release.cmd relwithdebinfo


12. That's all. If you want to debug Marble with plugins from Visual Studio, you have to do some more things:
a) in the source file QtMainWindow.cpp, function MainWindow::MainWindow() add the following line before creating instance of ControlView (or directly at the beginning of the function):
Code: Select all
QDir::setCurrent( qApp->applicationDirPath() );

b) after each build run make_release.cmd debug plugins_list.txt "%WORKBLD%\src\Debug" (replace %WORKBLD% with your build dir, see above).


Good luck! :-) Please tell if something wrong.


Bookmarks



Who is online

Registered users: bancha, Bing [Bot], Evergrowing, Google [Bot], lockheed, mesutakcan, Sogou [Bot]