0

I have compiled Mongo C++11 drivers successful on Windows 10 64 bit using MSBuild. When trying to run a test got the error message;

The ordinal 4694 could not be located in the dynamic library libmongoc-1.0.dll

After a search on how to force linking C++ libraries by name I was pointed to CMake's CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS option. After setting it within CMakeLists.txt for compiling Mongo C driver I still get the same error message, set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON) . I tried to set it in all the Mongo drivers (BSON, C and C++) and still get the same error message. I also tried it on the CMake command line -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON and got the same error message.

Am I using this option for the intended purpose or is there a different option to set?

Amani
  • 16,245
  • 29
  • 103
  • 153
  • I am not sure of the behavior of `-D` option for non-cache variable, but correct syntax for `set` command is `set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)`. Try this syntax before any target declaration – rocambille Jun 19 '17 at 11:33
  • Can you try replacing libmongoc-1.0.dll with just mongoc-1.0.dll (and similarly for libbson)? – Saghm Jun 20 '17 at 20:04

1 Answers1

0

CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS defines what to export, not how. And in fact, it would be pointless to combine with exporting by ordinal. Exporting by ordinal basically numbers the exported functions. Obviously this requires a stable mapping, as the importing and exporting side have to agree. But CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS builds the export table on the fly, which isn't going to be stable.

The real problem here is why you're importing ordinals. That's a 1990's era optimization. Just use names.

MSalters
  • 173,980
  • 10
  • 155
  • 350
  • I tried to use that CMake option after I got this error `The ordinal 4694 could not be located in the dynamic library libmongoc-1.0.dll` from compiling the Mongo C++ library as it is, as such was trying to find a way to avoid that as well. Do you have any suggestion as to how I can avoid that? I did nothing to change the original source code in the first place. – Amani Jun 19 '17 at 14:47
  • @Amani: You're entirely missing my point here. The problem is the EXE, which is using `4694`. Why? – MSalters Jun 19 '17 at 14:50
  • I bit not experienced when it comes to that area of C++. When compiling my EXE I did not specify anything to use `4694`. I just did call CMake like `cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=C:/install_mongo ../src`. – Amani Jun 19 '17 at 14:58
  • @Amani: Ok, last attempt: the problem is not with CMake, the problem is not with MongoDB. The problem is with that other program which you don't name. – MSalters Jun 19 '17 at 17:28
  • please see my other question [here](https://stackoverflow.com/questions/44635373/c-executable-keep-looking-for-ordinal-entry-point?noredirect=1#comment76256925_44635373) – Amani Jun 19 '17 at 17:31