Hello, I'd like to use C++ in my luarock "refser". However, I've met some problems with compiling it with built-in build back-end.
(Long text ahead, to cut it short: Visual Studio compiler needs a special option to compile C++, but built-in system can't provide it) The first problem is that it uses gcc instead of g++ even though source file extension is .cpp. I looked up a solution and added stdc++ to the libraries list of my module in the rockspec. However, this approach fails on windows as Visual Studio compiler(cl.exe) obviously can't find stdc++.lib, it compiles C++ fine without it(not really, see below). The solution I've found is to use platform overrides and provide an empty table for field "libraries" in the rockspec. On this stage it looks like this: http://raw.github.com/lua4web/refser/90fe/rockspecs/refser-git-1.rockspec (I think I should add "windows" into platforms table) Umfortunately, this is not enough as proper compiling C++ with cl.exe requires passing /EHsc option. I've tried fixing that with a hack, by adding /EHsc to the incdirs field in the rockspec: http://raw.github.com/lua4web/refser/60f8/rockspecs/refser-git-1.rockspec But that didn't work. Compiler just ignored the option. What's really strange is that when I manually copied command executed by luarocks: > cl /MD /O2 -c -Fosrc/crefser.obj -Ic:/LuaRocks//2.0/include src/crefser.cpp > -Isrc/ /EHsc and executed it manually in the command line prompt, it worked as expected. I know that I can just use make or cmake, but built-in system works really well to avoid any platform incompatibilities, and it's much cleaner, so I hope I'll find a way to use it for C++, too. I can think of two ways to solve the problem. The first is to extend rockspec format for built-in system and add "options" field: a string or an array of strings to be passed to compiler after other parameters. It could also used to override some options(i.e. use different optimisation level). Another solution I can think of is to add some basic C++ support into luarocks. It could automatically provide -lstdc++ option for gcc and /EHsc for cl and whatever other compilers might need for .gcc source files. Both of my suggestions are not backward-compatible, so they might be implemented in the 2.1 version. Yet I hope to find a solution for existing luarock version. Any help would be appreciated. Thanks, Peter ------------------------------------------------------------------------------ See everything from the browser to the database with AppDynamics Get end-to-end visibility with application monitoring from AppDynamics Isolate bottlenecks and diagnose root cause in seconds. Start your free trial of AppDynamics Pro today! http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk _______________________________________________ Luarocks-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/luarocks-developers
