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

mingw-w64 builds fail due to "export ordinal too large" #3672

Closed
FSund opened this issue Feb 25, 2020 · 3 comments · Fixed by #3694
Closed

mingw-w64 builds fail due to "export ordinal too large" #3672

FSund opened this issue Feb 25, 2020 · 3 comments · Fixed by #3694

Comments

@FSund
Copy link
Contributor

FSund commented Feb 25, 2020

I'm trying to compile pcl using mingw-w64 GCC from MSYS2, but I get the error C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: error: export ordinal too large: 93998

Full error with context

[ 25%] Linking CXX shared library ../bin/libpcl_features.dll
cd /C/msys64/home/filip.sund/code/pcl/build/features && /C/msys64/mingw64/bin/cmake.exe -E remove -f CMakeFiles/pcl_features.dir/objects.a
cd /C/msys64/home/filip.sund/code/pcl/build/features && /C/msys64/mingw64/bin/ar.exe cr CMakeFiles/pcl_features.dir/objects.a "CMakeFiles/pcl_features.dir/src/board.cpp.obj" "CMakeFiles/pcl_features.dir/src/flare.cpp.obj" "CMakeFiles/pcl_features.dir/src/brisk_2d.cpp.obj" "CMakeFiles/pcl_features.dir/src/boundary.cpp.obj" "CMakeFiles/pcl_features.dir/src/cppf.cpp.obj" "CMakeFiles/pcl_features.dir/src/cvfh.cpp.obj" "CMakeFiles/pcl_features.dir/src/our_cvfh.cpp.obj" "CMakeFiles/pcl_features.dir/src/crh.cpp.obj" "CMakeFiles/pcl_features.dir/src/don.cpp.obj" "CMakeFiles/pcl_features.dir/src/fpfh.cpp.obj" "CMakeFiles/pcl_features.dir/src/gasd.cpp.obj" "CMakeFiles/pcl_features.dir/src/gfpfh.cpp.obj" "CMakeFiles/pcl_features.dir/src/integral_image_normal.cpp.obj" "CMakeFiles/pcl_features.dir/src/intensity_gradient.cpp.obj" "CMakeFiles/pcl_features.dir/src/intensity_spin.cpp.obj" "CMakeFiles/pcl_features.dir/src/linear_least_squares_normal.cpp.obj" "CMakeFiles/pcl_features.dir/src/moment_invariants.cpp.obj" "CMakeFiles/pcl_features.dir/src/moment_of_inertia_estimation.cpp.obj" "CMakeFiles/pcl_features.dir/src/multiscale_feature_persistence.cpp.obj" "CMakeFiles/pcl_features.dir/src/narf.cpp.obj" "CMakeFiles/pcl_features.dir/src/normal_3d.cpp.obj" "CMakeFiles/pcl_features.dir/src/normal_based_signature.cpp.obj" "CMakeFiles/pcl_features.dir/src/organized_edge_detection.cpp.obj" "CMakeFiles/pcl_features.dir/src/pfh.cpp.obj" "CMakeFiles/pcl_features.dir/src/ppf.cpp.obj" "CMakeFiles/pcl_features.dir/src/shot.cpp.obj" "CMakeFiles/pcl_features.dir/src/shot_lrf.cpp.obj" "CMakeFiles/pcl_features.dir/src/spin_image.cpp.obj" "CMakeFiles/pcl_features.dir/src/principal_curvatures.cpp.obj" "CMakeFiles/pcl_features.dir/src/rift.cpp.obj" "CMakeFiles/pcl_features.dir/src/rops_estimation.cpp.obj" "CMakeFiles/pcl_features.dir/src/rsd.cpp.obj" "CMakeFiles/pcl_features.dir/src/grsd.cpp.obj" "CMakeFiles/pcl_features.dir/src/statistical_multiscale_interest_region_extraction.cpp.obj" "CMakeFiles/pcl_features.dir/src/vfh.cpp.obj" "CMakeFiles/pcl_features.dir/src/esf.cpp.obj" "CMakeFiles/pcl_features.dir/src/3dsc.cpp.obj" "CMakeFiles/pcl_features.dir/src/usc.cpp.obj" "CMakeFiles/pcl_features.dir/src/range_image_border_extractor.cpp.obj"
cd /C/msys64/home/filip.sund/code/pcl/build/features && /C/msys64/mingw64/bin/g++.exe   -Wabi=11 -Wall -Wextra -Wno-unknown-pragmas -fno-strict-aliasing -Wno-format-extra-args -Wno-sign-compare -Wno-invalid-offsetof -Wno-conversion -march=native -msse4.2 -mfpmath=sse  -mwin32 -mthreads -O3 -DNDEBUG -Wl,--as-needed -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--allow-multiple-definition  -mthreads -shared -o ../bin/libpcl_features.dll -Wl,--out-implib,../lib/libpcl_features.dll.a -Wl,--major-image-version,1,--minor-image-version,10 -Wl,--whole-archive CMakeFiles/pcl_features.dir/objects.a -Wl,--no-whole-archive  /C/msys64/mingw64/lib/libboost_filesystem-mt.a /C/msys64/mingw64/lib/libboost_date_time-mt.a /C/msys64/mingw64/lib/libboost_iostreams-mt.a /C/msys64/mingw64/lib/libboost_system-mt.a /C/msys64/mingw64/lib/libboost_regex-mt.a -lm -lgomp ../lib/libpcl_filters.dll.a ../lib/libpcl_search.dll.a ../lib/libpcl_kdtree.dll.a /C/msys64/usr/lib/libflann_cpp.dll.a ../lib/libpcl_octree.dll.a ../lib/libpcl_sample_consensus.dll.a ../lib/libpcl_common.dll.a /C/msys64/mingw64/lib/libboost_filesystem-mt.a /C/msys64/mingw64/lib/libboost_date_time-mt.a /C/msys64/mingw64/lib/libboost_iostreams-mt.a /C/msys64/mingw64/lib/libboost_system-mt.a /C/msys64/mingw64/lib/libboost_regex-mt.a -lm -lgomp -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: error: export ordinal too large: 93998
collect2.exe: error: ld returned 1 exit status
make[2]: *** [features/CMakeFiles/pcl_features.dir/build.make:672: bin/libpcl_features.dll] Error 1
make[2]: Leaving directory '/home/filip.sund/code/pcl/build'
make[1]: *** [CMakeFiles/Makefile2:1512: features/CMakeFiles/pcl_features.dir/all] Error 2
make[1]: Leaving directory '/home/filip.sund/code/pcl/build'
make: *** [Makefile:152: all] Error 2

Exact steps to reproduce are:

cd pcl
mkdir build
cd build
cmake -G"MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr ..
make

I've had to add add_definitions(-D_USE_MATH_DEFINES) to CMakeLists.txt to avoid issues with M_PI not being defined. I've also added the #ifdef _WIN32 fix to pcd_grabber.cpp mentioned in #3667. I'll make some PR's regarding this when I've gotten everything to compile.

A suggested fix I found somewhere was to add -Wa,-mbig-obj to CMAKE_CXX_FLAGS, but that didn't help.

Your Environment

  • Operating System and version: Windows 10, Version 10.0.18363 Build 18363
  • Compiler: g++.exe (Rev2, Built by MSYS2 project) 9.2.0
  • CMake: cmake version 3.16.4
  • PCL Version: commit 6657995
@larshg
Copy link
Contributor

larshg commented Feb 25, 2020

Seems you are hitting the same limit as VS linker has.
See #833 - so maybe if you add -DPCL_ONLY_CORE_POINT_TYPES it will succeed. But if you have to use specific point types you apparently need to import the required .hpp file.

@FSund
Copy link
Contributor Author

FSund commented Feb 25, 2020

That sounds promising, I'll try that.

BTW, I think the /bigobj flag could maybe be used to avoid the issue seen #833. https://docs.microsoft.com/en-us/cpp/build/reference/bigobj-increase-number-of-sections-in-dot-obj-file?view=vs-2019

EDIT: Nevermind, I see the /bigobj is already enabled for MSVC: https://github.com/PointCloudLibrary/pcl/blob/master/CMakeLists.txt#L149

@FSund
Copy link
Contributor Author

FSund commented Feb 25, 2020

Compilation succeeded after I added add_definitions(-DPCL_ONLY_CORE_POINT_TYPES), so this should probably be added for all mingw-w64 builds. Perhaps around here, in a if(MINGW)? But outside the if(PCL_SHARED_LIBS), because I got the same error with PCL_SHARED_LIBS=FALSE.

EDIT: On second thought, the issue seems to be Windows-specific, so it's perhaps best suited in a separate section, not inside the if(CMAKE_COMPILER_IS_GNUCXX). Maybe something like this (not sure how common MINGW is, but it's used a couple of times in the main CMakeLists.txt)

if(WIN32)
  if(CMAKE_COMPILER_IS_MSVC OR MINGW)
    add_definitions(-DPCL_ONLY_CORE_POINT_TYPES)
  endif()
endif()

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

Successfully merging a pull request may close this issue.

3 participants