sqlite_orm icon indicating copy to clipboard operation
sqlite_orm copied to clipboard

sqlite-orm fails to compile under uwp

Open jimwang118 opened this issue 1 year ago • 3 comments

When I failed to compile sqlite-orm under uwp, the error message is as follows.

MSVCRTD.lib(exe_main.obj) : error LNK2019: unresolved external symbol main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)
tests\unit_tests.exe : fatal error LNK1120: 1 unresolved externals
ninja: build stopped: subcommand failed.

I have enabled the test feature. This feature generates the unit_tests.exe executable program, but under uwp there is an error message indicating that there is no corresponding executable main function entry? Is this a normal design or is it a problem?

jimwang118 avatar Nov 29 '23 08:11 jimwang118

We are using Catch2 v3 for unit testing. Do you know whether it is supported on UWP, or whether it needs special handling?

tests\CMakeLists.txt links against Catch2::Catch2WithMain:

target_link_libraries(unit_tests PRIVATE sqlite_orm Catch2::Catch2WithMain)

trueqbit avatar Nov 29 '23 21:11 trueqbit

@jimwang118 does it work now?

fnc12 avatar May 16 '24 06:05 fnc12

@jimwang118 does it work now?

Still the compilation failed.

jimwang118 avatar May 16 '24 06:05 jimwang118

vcpkg's “x64-uwp” triplet sets the CMake variable CMAKE_SYSTEM_NAME=WindowsStore, which instructs CMake to add the /D_UNICODE and /DUNICODE compiler flags. Catch2 v3 will then provide a definition of wmain() instead of main().

For some reason, the msvc linker will not take wmain() from a static library.

PR #1295 explicitly sets the entry point of the unit test executable file.

trueqbit avatar May 18 '24 16:05 trueqbit

@jimwang118 I have tested the “x64-uwp” triplet, but it would be good if you could check that too.

trueqbit avatar May 18 '24 20:05 trueqbit

Thanks @jimwang118 and @RealChuan for making sure this works.

trueqbit avatar May 29 '24 14:05 trueqbit