ihedvall / mdflib

Implementation of the ASAM MDF data file.
https://ihedvall.github.io/mdflib/
MIT License
76 stars 32 forks source link

Problem using mdflib in custom project #49

Closed TheElesty closed 12 months ago

TheElesty commented 1 year ago

When trying to use mdflib (installed using .exe file in both main and release 2.0.0), I am unable to compile the test project. Tested in CLion with Visual Studio 2017/2022 and NMake generator

MDF lib v2.0.0 CLion with NMake generator: image

CLion with Visual Studio 15 2017 generator: image

CLion with Visual Studio 17 2022 generator: image

Visual Studio 2022: image

When using version form main (using CLion with Visual Studio 15 2017 generator) I got this: image image

I tried also to build lib from source, but without success (again in both vs17 and vs22). I was able to build mdflib target in vs 17, but for mdflibrary I got an error that build tools are incorrect, and even after retargeting solution it won't change.

ihedvall commented 1 year ago

Sorry that building causing problem. The best way to build is to use cmake. The CMakeList.txt configuration file unfortunately have the MDF_SHARED_LIB=ON. This means that also the C# interface is built which CMake handle but not CLion. If you turn off the C# interface build, most of your errors will disappear.

The MDF library is dependent on 2-5 external libraries,The C++ library depends on ZLIB and EXPAT. The unit test is dependent on the Google Unit test while the MdfViewer are dependent on WxWindows and Boost.

Basically there exist 3 different way to solve external dependencies. The first solution is to use an external component path. See the COMP_DIR option below. This is the preferred solution if "you" are many user of the library. This is typical used by companies. The ihedvall/components repository includes script files for building external libraries.

The second way is to replace the component path with vcpkg. The vcpkg is little bit funky but it will build all external dependencies for you on the fly. It will take some more compilation time at the first build (boost and wxWindows). This functionality is newly added.

The third way is let CMake download the external libraries if they are missing. This works OK for smaller libraries as Google unit test, ZLIB and expat but doesn't work for GUI (boost/wxWindows) . I think this is your current mode.

My current CLion settings are as below:
image

Simplxss commented 1 year ago

Please build mdf library before building mdf_test. I think you need a chicken before you want a egg.

TheElesty commented 1 year ago

Please build mdf library before building mdf_test. I think you need a chicken before you want a egg.

mdf_test is my testing project using mdf.lib from instalator

Simplxss commented 1 year ago

Sorry, I have not seen that you are using the library from installator. Can you try to use the .lib from github action? https://github.com/ihedvall/mdflib/actions/runs/6019755660

Note: you may still need the lib of dependeces(zlib, expat) to link.

TheElesty commented 1 year ago

Thank, will try both suggestion and I let u know if that worked

ihedvall commented 1 year ago

I don't like this .NET Framework... stuff in the compiler. Just wondering if the /clr compiler option is set in Visual Studio ?

TheElesty commented 12 months ago

So using prebuild lib from github action works. Thanks for fast response