Skip to content

Compile with TDM-GCC 32 on Windows #32

Description

@brynne8

I finally successfully compiled the library on Windows with mingw32 (TDM-GCC), with some modifications. I opened this issue to see if the compilation process could be improved.

--- file2.hpp	2019-05-27 19:30:14.480608100 +0800
+++ file.hpp	2019-05-26 19:06:07.831800400 +0800
@@ -7,13 +7,7 @@
 namespace file {
 	inline FILE* open(const char* filename, const char* mode)
 	{
-#if WIN32
-		FILE* fp = nullptr;
-		fopen_s(&fp, filename, mode);
-		return fp;
-#else
 		return fopen(filename, mode);
-#endif
 	}
 }

It seems to work well but in the last step (linking)

-- LUA_RAPIDJSON_VERSION: 0.5.0
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Program Files (x86)/lua-rapidjson-0.5.0/build.luarocks
[ 20%] Linking CXX shared module rapidjson.dll
g++.exe: error: C:Program Files (x86)LuaRocks/lua5.1.dll: No such file or directory
CMakeFiles\lua-rapidjson.dir\build.make:134: recipe for target 'rapidjson.dll' failed
mingw32-make.exe[2]: *** [rapidjson.dll] Error 1
CMakeFiles\Makefile2:71: recipe for target 'CMakeFiles/lua-rapidjson.dir/all' failed
mingw32-make.exe[1]: *** [CMakeFiles/lua-rapidjson.dir/all] Error 2
Makefile:128: recipe for target 'all' failed
mingw32-make.exe: *** [all] Error 2

Error: Build error: Failed building.

I found the C:Program Files (x86)LuaRocks/lua5.1.dll was wrong because the backslash \ is regarded as escape character. I don't know how to change the CMake configuration, so I manually modified build.luarocks/CMakeFiles/lua-rapidjson.dir/linklibs.rsp to something like

"C:/Program Files (x86)/LuaRocks/lua5.1.dll" -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 

And ran

C:\TDM-GCC-32\bin\g++.exe  -O3 -DNDEBUG  -shared -o rapidjson.dll -Wl,--major-image-version,0,--minor-image-version,0 -Wl,--whole-archive CMakeFiles\lua-rapidjson.dir/objects.a -Wl,--no-whole-archive @CMakeFiles\lua-rapidjson.dir\linklibs.rsp

And succeeded! The compiled dll is here
rapidjson.zip

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions