win10 + vs2017 + cmake3.17 compile OSG-3.4.1

There are many bugs in it, and I have already solved them. This blog is only for my own notes, the writing is not very standardized and is for your reference only.

Reference tutorial: https://blog.csdn.net/bailang_zhizun/article/details/120992244

Note:

1. Uncheck BUILD_OSG_EXAMPLE and BUILD_MFC_EXAMPLE.

CMakeLists.txt can build these examples normally, but it is not configured to install these examples.

After checking these two options, VS2017 will INSTALL these examples by default, but CMake does not configure the instructions to install these examples, so it will fail.

If you want to build related examples, you can wait until the Install process is completed and then reconfigure to specifically build related examples.

2. When configuring CMAKE, CMAKE_BUILD_TYPE defaults to Release only, and Debug needs to be added as well.

3. CMake-gui lists many dependent libraries. You can find them from dependency libraries packaged by others (reference:), or you can recompile yourself (reference: GitHub – bjornblissing/osg-3rdparty- cmake: CMake scripts for building OpenSceneGraph third party libraries.). If there are dependent libraries that are not included in other people’s packaging libraries and you have not compiled them yourself, you can clear the corresponding information to avoid unnecessary errors.

4. If there are other bugs, please refer to the reference tutorial below.

1. Download and unzip

2. Modify configure

1) Ungrouped Entries — 》ACTUAL_3RDPARTY_DIR:

Set to: D:/Depend_3rd_party/OSG341/3rdParty

2) Ungrouped Entries–》SDL_INCLUDE_DIR:

Set to: D:/Depend_3rd_party/SDL2/install/include/SDL2 (compiled by yourself)

3) Ungrouped Entries–》SDL2MAIN_LIBRARY:

Set to: D:/Depend_3rd_party/SDL2/install/lib/SDL2main.lib (compiled by yourself)

4) Ungrouped Entries–》SDLMAIN_LIBRARY:

Set to: D:/Depend_3rd_party/SDL2/install/lib/SDL2main.lib (compiled by yourself)

5) BUILD–>BUILD_OSG_EXAMPLES

Set to: Empty

6) CMAKE–>CMAKE_CONFIGURATION_TYPES

Set to: Debug;Release

7) CMAKE –> CMAKE_INSTALL_PREFIX: (Important)

Set to: D:/Depend_3rd_party/OSG341/install (a folder created by yourself)

8) FREETYPE (can be configured without configuration)

9) GDAL (can be configured without configuration)

10)SDL2

3. Configure:

4. Update Ungrouped Entries again:

1) Check BUILD_MFC_EXAMPLES (remember!!! VS2017 must install the MFC development component!!!)

2) SDL2_LIBRARY is set to (no need to update):

D:/Depend_3rd_party/SDL2/install/lib/SDL2main.lib;D:/Depend_3rd_party/SDL2/install/lib/SDL2.lib;D:/Depend_3rd_party/SDL2/install/lib/SDL2d.lib;D:/Depend_3rd_party/ SDL2/install/lib/SDL2maind.lib

5. Configure again:

6. Generate:

7. Open Project:

Select release mode; right-click ALL_BUILD–>Generate, long wait, about 1.5 hours.

8. Error report:

1) nvtt.lib (CompressionOptions.obj): error LNK2001: Unresolved external symbol “int __cdecl nvAbort:”—not yet resolved

Error location: An error occurs when generating the Plugins nvtt plug-in.

Possible reason 1: The compilation format of nvtt.lib is wrong, re-download the nvtt source code and recompile

Execution result: Not working.

Possible reason 2: Manually add the nvtt lib library to the link library of the Plugins nvtt project

Modification process:https://www.cnblogs.com/hik-wxy/p/14715116.html

Modification result: Not working.

The specific details are as follows:

1) Right-click the corresponding project→Properties→VC++ Directory→Library Directory

2) Right-click the corresponding project→Properties→Linker→Input→Additional Dependencies

The filling content is:

nvtt.lib
nvtt_d.lib
nvcore.lib
nvcore_d.lib
nvimage.lib
nvimage_d.lib
nvmath.lib
nvmath_d.lib
nvthread.lib
nvthread_d.lib
squish.lib
squish_d.lib
bc7.lib
bc7_d.lib
bc6h.lib
bc6h_d.lib

Final solution:

Neither of the above methods work. Because this project is a plug-in for NVIDIA graphics cards to support osg display, it is not particularly important. Therefore, during the second compilation process, the NVTT configuration information is deleted on the cmake-gui interface, so that it will not be used during compilation. Compile this plugin.

Reference tutorial:

[1] OSG + VS2017 environment construction under windows10-CSDN blog

[2] OSG environment deployment OSG3.6.5 + vs2017 + win10_x64 (super detailed)

[3] Detailed process of compiling OSG under Win64 (Win10 + VS2015 + OSG3.6.3)