-
Notifications
You must be signed in to change notification settings - Fork 31
Additional Library Directories on Linker property page is a trap #29
Comments
Yeah, I agree there is a problem here... I'll do some testing on this. I definitely don't want to require users to start naming their libraries in the format "libStaticLib.a/bc/lib". |
Any thoughts on how to fix this? I just found an issue with emcc when using -l that is going to have to be fixed for any solution to this problem to work. It expands libraries, e.g. -lfoo only to libfoo.a; however when the found libfoo.a is passed to a later stage of the linker, it complains .a is an unknown suffix. If you change the name to libfoo.bc then the library is not found. See Emscripten issue 2471. |
For (Windows) Emscripten development, my recommendation is that people should always use the suffix I commented on the mailing list on this. Let's see what others think. |
Once Emscripten issue 2471 is fixed, vs-tool will need to add the -l prefixes when it adds the names appearing in the AdditionalDependencies list to the link command. |
Yeah.. The newly released Emsdk 1.21.0 release http://tiny.cc/2npmix still has this issue, but let's hope we'll be able to fix it by the next release. |
Just tried 1.22.0. emlink/emcc no longer matches x.dll but that is the only thing fixed. In order to avoid having to change the names of "Additional Dependencies" when generating an Emscripten config from a Win32 or x64 config, -lx.lib or -llibx.lib need to work. The former case should match libx.lib or x.lib, the latter libx.lib. This is also needed for my case, generating project files with GYP, because GYP does not support per configuration library names. vs-tool still needs to prefix the library names with -l when passing them to emlink/emcc to make it search Please can this be fixed in the next release? |
I started to look into fixing this but can't find any documentation about VS platforms. If you can give me a clue where to start, e.g. where/how is What I plan to do, if I can figure out how, is to prefix each item in AdditionalDependencies with -l and remove its filename extension, if any. |
I believe that is done in the DLL that is being reused from https://code.google.com/p/vs-android/, try peeking into the sources of that project. |
I have investigated this some more. If you add the attribute 'Switch="l"' (small L) to the AdditionalDependencies StringListProperty in emcc_link.xml, then the libraries will be prefixed with "-l". emlink will then search for libraries along the search path given by AdditionalLibraryDirectories. There is still the issue with library naming. There is currently no name that will work for both the MSVS linker and emlink. For the MSVS linker, libraries have to be foo.lib for it to search LIBPATH: directories. When emlink sees -lfoo.lib it returns Can we change emlink to ignore an existing extension or else not tack another extension on the end? The former may be preferable because library files can then use the Emscripten naming conventions. Such behavior should probably be behind an option flag. |
So if user passes |
I opened emscripten-core/emscripten#2986 for Alon. I verified that emlink currently searches for foo.lib.bc and foo.lib.a in this case. I didn't try foo.lib.lib. |
The emcc linker property page contains an Additional Library Directories property, just like the Win32 link property page. Unfortunately this property is not useful with the emcc linker (gcc link) because -L directives (which is how these directories are passed) are only used to search for libraries specified with -l directives. vs-tool does not use -l. It simply appends the libraries specified in the "Additional Dependencies" property to the end of the link command. This is the same way the corresponding Win32 properties are handled but in that case the linker searches the /L directories.
I propose that vs-tool specify the Additional Dependencies using -l directives. This does mean the library name will have to be changed, removing any 'lib' prefix and '.lib' extension. The extension likely has to be changed to .bc anyway so this is probably not too big an issue.
Currently you have to change the library name anyway to add its relative path from the MSVS project file otherwise it will not be found in an Emscripten config generated from a Win32 config that uses Additional Library Directories.
The text was updated successfully, but these errors were encountered: