thelfer / MFrontGenericInterfaceSupport

This project aims at providing support for MFront generic behaviours. This project can be embedded in open-source and propriary sofware
37 stars 35 forks source link

MGIS Cross-compiling Windows #8

Closed TeroFrondelius closed 5 years ago

TeroFrondelius commented 5 years ago

Hi, I'm trying to cross-compile Windows binaries and got this error message:

[ 55%] Linking CXX shared library libMFrontGenericInterface.dll
CMakeFiles/MFrontGenericInterface.dir/objects.a(Integrate.cxx.obj):Integrate.cxx:(.text+0x113a): undefined reference to `__atomic_fetch_add_4'
CMakeFiles/MFrontGenericInterface.dir/objects.a(Integrate.cxx.obj):Integrate.cxx:(.text+0x11de): undefined reference to `__atomic_fetch_add_4'
CMakeFiles/MFrontGenericInterface.dir/objects.a(Integrate.cxx.obj):Integrate.cxx:(.text+0x124a): undefined reference to `__atomic_fetch_add_4'
CMakeFiles/MFrontGenericInterface.dir/objects.a(Integrate.cxx.obj):Integrate.cxx:(.text+0x12ee): undefined reference to `__atomic_fetch_add_4'
CMakeFiles/MFrontGenericInterface.dir/objects.a(Integrate.cxx.obj):Integrate.cxx:(.text+0x2178): undefined reference to `__atomic_fetch_add_4'
CMakeFiles/MFrontGenericInterface.dir/objects.a(Integrate.cxx.obj):Integrate.cxx:(.text+0x23f8): more undefined references to `__atomic_fetch_add_4' follow
collect2: error: ld returned 1 exit status
make[2]: *** [src/CMakeFiles/MFrontGenericInterface.dir/build.make:311: src/libMFrontGenericInterface.dll] Error 1
make[1]: *** [CMakeFiles/Makefile2:186: src/CMakeFiles/MFrontGenericInterface.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
ERROR: LoadError: Build for mgis_binaries on i686-w64-mingw32-gcc7-cxx11 did not complete successfully

Here is the full output: https://travis-ci.org/TeroFrondelius/mgisBuilder/builds/558838925?utm_source=github_status&utm_medium=notification

thelfer commented 5 years ago

Hi Tero, It seems that this is a side effect of removing --march=native (-Denable-portable-build=ON). See this thread: https://stackoverflow.com/questions/35884832/compile-error-undefined-reference-to-atomic-fetch-add-4 Would you try to enable this option again to see if this solve the issue ?

TeroFrondelius commented 5 years ago

Yes, I will try. Thanks for your help.

TeroFrondelius commented 5 years ago

@thelfer sorry for the stupid question, but can I do it like this:

cmake -DCMAKE_CXX_FLAGS="-march=native"
thelfer commented 5 years ago

Unfortunately no. For (probably) bad reasons, CMAKE_CXX_FLAGS is overriden during the configuration steps.

TeroFrondelius commented 5 years ago

Alright, no problem. I will try again, now interactively. Now I'm more convinced that I will need a good linux laptop as a work computer.

TeroFrondelius commented 5 years ago

Unfortunately no. For (probably) bad reasons, CMAKE_CXX_FLAGS is overriden during the configuration steps.

It looks like the CXXFLAGS is overwritten. I tried adding set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native") both at the beginning and at the end of the file CMakeLists.txt, but it didn't help. I will try to dig deeper and find where is it overwritten.

TeroFrondelius commented 5 years ago

I used ccmake to interactively study the environment and I got the -march=native and -latomic correctly. Maybe it is something else.

TeroFrondelius commented 5 years ago

I got it working. I needed these changes in the CMakeLists.txt:

link_libraries("-latomic")
include_directories($prefix/include/julia)

I think the latter is because of the "collapsed" folder structure. Anyway one step forward. Here is the link to the actual implementation: https://github.com/TeroFrondelius/mgisBuilder/blob/52c30b37acd43bb286ec269cd34241323d00fb28/build_tarballs.jl#L28-L30