diff --git a/gen/linker.cpp b/gen/linker.cpp index a1d94259..ce880239 100644 --- a/gen/linker.cpp +++ b/gen/linker.cpp @@ -262,21 +262,23 @@ int linkObjToBinary(bool sharedLib) output = FileName::removeExt((char*)global.params.objfiles->data[0]); else output = "a.out"; + + if (sharedLib) { + std::string libExt = std::string(".") + global.dll_ext; + if (!endsWith(output, libExt)) + { + if (global.params.os != OSWindows) + output = "lib" + output + libExt; + else + output.append(libExt); + } + args.push_back("-shared"); + } else if (global.params.os == OSWindows && !endsWith(output, ".exe")) { + output.append(".exe"); + } } - if (sharedLib) { - std::string libExt = std::string(".") + global.dll_ext; - if (!endsWith(output, libExt)) - { - if (global.params.os != OSWindows) - output = "lib" + output + libExt; - else - output.append(libExt); - } - args.push_back("-shared"); - } else if (global.params.os == OSWindows && !endsWith(output, ".exe")) { - output.append(".exe"); - } + args.push_back("-o"); args.push_back(output.c_str()); diff --git a/gen/main.cpp b/gen/main.cpp index f2fcbee5..056187e8 100644 --- a/gen/main.cpp +++ b/gen/main.cpp @@ -407,9 +407,12 @@ int main(int argc, char** argv) error("flags conflict with -run"); fatal(); } - else - { - if (global.params.objname && files.dim > 1 && !singleObj) + else if (global.params.objname && files.dim > 1) { + if (createStaticLib || createSharedLib) + { + singleObj = true; + } + if (!singleObj) { error("multiple source files, but only one .obj name"); fatal();