Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux Ubuntu compilation issue #34

Open
xmirabel opened this issue Apr 7, 2023 · 9 comments
Open

Linux Ubuntu compilation issue #34

xmirabel opened this issue Apr 7, 2023 · 9 comments

Comments

@xmirabel
Copy link

xmirabel commented Apr 7, 2023

Contexts of compilation:

  • Microsoft Visual Studio Pro 2022 with Linux workload.
  • Configuration with vcpkg

a/ Windows 10 mode:

  • Compilation on: Local computer + x64 Debug
    => compilation ok

b/ Linux mode:

  • Microsoft Windows WSL2
  • Linux Ubuntu 22.04.2 LTS (GNU/Linux 5.15.90.1-microsoft-standard-WSL2 x86_64)
  • Compilation on: WSL: Ubuntu + Linux Debug

CMake Error:
Running
'/usr/bin/ninja' '-C' '/home/xmirabel/.vs/fmi-library-master/out/build/linux-debug' '-t' 'recompact'
failed with:
ninja: error: build.ninja:4558: multiple rules generate ExpatEx/libexpat.a [-w dupbuild=err] C:\R\fmi-library-master\ ninja

How can I solve it, please?

@mahge
Copy link

mahge commented Apr 11, 2023

@xmirabel maybe the fixes in #7 work for you as well. That is how I solved issues with expat. IIRC we encountered your issue at some point as well. fmil probably has more issues with Ninja so one suggestion is to look at the OpenModelica's FMIL modifications and port them to your project.

@xmirabel
Copy link
Author

Dear M. @mahge, the fix #7 is on expat-2.1.0.
At the moment, I have just tried on the latest version downloaded: expat-2.4.8, and the CMakelist have changed a lot. So I am not able to adapt it (I am not at all a fine blade in cmake configuration).

@mahge
Copy link

mahge commented Apr 11, 2023

I think it should be fine. You just need to adjust it a bit

first delete all these lines:
https://github.com/modelon-community/fmi-library/blob/master/Config.cmake/fmixml.cmake#L188-L257

and add this where the lines used to be

### Set the options of expat and add it as subdirectory.
option(EXPAT_BUILD_TOOLS "build the xmlwf tool for expat library" OFF)
option(EXPAT_BUILD_EXAMPLES "build the examples for expat library" OFF)
option(EXPAT_BUILD_TESTS "build the tests for expat library" OFF)
option(EXPAT_SHARED_LIBS "build a shared expat library" OFF)
option(EXPAT_DTD "Define to make parameter entity parsing functionality available" OFF)
option(EXPAT_NS "Define to make XML Namespaces functionality available" OFF)
add_subdirectory(ThirdParty/Expat/expat-2.4.8)

set(EXPAT_INCLUDE_DIRS ThirdParty/Expat/expat-2.4.8)

then try recompiling and hopefully it should go fine.


If you have no specific reason for choosing fmi-library, I suggest you take a look at https://github.com/robbr48/fmi4c. It should be easier to build and is generally more lightweight.

@xmirabel
Copy link
Author

I have just tried the OpenModelica's FMIL modifications.

First, it seems that OpenModelica/OMCompiler-3rdParty root CMakeLists.txt uses Open Modelica specific extensions: "omc_add_subdirectory".
I do not know how to make them compatible with ninja?

Second, if I open OpenModelica/OMCompiler-3rdParty/FMIL directory with Visual Studio Pro 2022 with WSL:Ubuntu + Linux Debug configuration (automatic CMakePresets.json) a certain number of errors occurs:

Group of errors 1: install DIRECTORY given no DESTINATION.
Solution: add "TYPE INCLUDE" before DESTINATION:

in FMIL/CMakeLists.txt
install(FILES
"${FMILibrary_BINARY_DIR}/fmilib_config.h"
"${FMILibrary_BINARY_DIR}/fmilib.h"
TYPE INCLUDE
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

install(DIRECTORY
${FMIIMPORTDIR}/include/
${JMUTILDIR}/include/
TYPE INCLUDE
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.h")

install(DIRECTORY
${FMILIB_FMI_STANDARD_HEADERS}/FMI1
${FMILIB_FMI_STANDARD_HEADERS}/FMI2
TYPE INCLUDE
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.h")

And in expat-2.1.0/CMakeLists.txt:

install(FILES lib/expat.h lib/expat_external.h
TYPE INCLUDE
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

@mahge
Copy link

mahge commented Apr 11, 2023

I think this might work for you. I mentioned the OpenModelica code just as reference to cross-check changes and get some ideas from. I don' think it can be directly copied. Check the comment above and I will try to help you as much as I can.

@xmirabel
Copy link
Author

I have another group of errors in runtime_test.cmake:
file COPY cannot find
"/home/xmirabel/.vs/FMIL/Test/try_to_uncompress_this_file.zip": No such
file or directory.

concerned lines:
file(COPY "${UNCOMPRESSED_DUMMY_FILE_PATH_SRC}" DESTINATION "${UNCOMPRESSED_DUMMY_FOLDER_PATH_DIST}")

and

file(COPY "${COMPRESS_DUMMY_FILE_PATH_SRC}" DESTINATION "${COMPRESS_DUMMY_FOLDER_PATH_DIST}")

I have to investigate

@xmirabel
Copy link
Author

I solved it by setting the cache variable : "FMILIB_BUILD_TESTS" to "false"

@xmirabel
Copy link
Author

Now, I built: error: "unable to find source file "zlib.h".
I have to investigate which variable to set?

@xmirabel
Copy link
Author

I have just read your message now and tried it:

first delete all these lines: [...]
and add this where the lines used to be [...]
then try recompiling and hopefully it should go fine.

Then the compilation on WSL: Ubuntu + Linux Release is building and installing fine!
Many thankx.

PS: And it continues to build and install on Windows.

If you have no specific reason for choosing fmi-library, I suggest you [...]

In fact, I have a good reason to use it.
I want to be able to compile libcosim from Open Simulation Platform.
But I would like to use vcpkg and MS Visual Studio Pro 2022 with Linux workload and WSL2, instead of conan like they do.

That is why I have another question: how does it works to update vcpkg with a new fmilib version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants