瀏覽代碼

Fix link errors when creating standalone executable

Modern g++ compilers such as that found on Ubuntu 11.10 require that
libraries are specified after the object files that might link them
on the command line.

We were generating a command line with the .o file at the end, so we
got link errors.

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 13 年之前
父節點
當前提交
aa2b7d8e63
共有 2 個文件被更改,包括 4 次插入1 次删除
  1. 3 1
      system/jlib/jcomp.cpp
  2. 1 0
      system/jlib/jcomp.ipp

+ 3 - 1
system/jlib/jcomp.cpp

@@ -294,7 +294,7 @@ void CppCompiler::addLibrary(const char * libName)
     {
         quote = "\"";
     }
-    linkerOptions.append(" ").append(USE_LIB_FLAG[targetCompiler]).append(quote).append(lname).append(USE_LIB_TAIL[targetCompiler]).append(quote);
+    linkerLibraries.append(" ").append(USE_LIB_FLAG[targetCompiler]).append(quote).append(lname).append(USE_LIB_TAIL[targetCompiler]).append(quote);
 }
 
 void CppCompiler::addLibraryPath(const char * libPath)
@@ -484,6 +484,8 @@ bool CppCompiler::doLink()
     ForEachItemIn(i0, allSources)
         cmdline.append(" ").append("\"").append(targetDir).append(allSources.item(i0)).append(".").append(OBJECT_FILE_EXT[targetCompiler]).append("\"");
 
+    cmdline.append(linkerLibraries);
+
     StringBuffer outName;
     outName.append(createDLL ? SharedObjectPrefix : NULL).append(CORE_NAME).append(createDLL ? SharedObjectExtension : ProcessExtension);
     cmdline.append(LINK_TARGET[targetCompiler]).append("\"").append(targetDir).append(outName).append("\"");

+ 1 - 0
system/jlib/jcomp.ipp

@@ -67,6 +67,7 @@ protected:
     StringBuffer    compilerOptions;
     StringAttr      libraryOptions;
     StringBuffer    linkerOptions;
+    StringBuffer    linkerLibraries;
     StringAttr      sourceDir;
     StringAttr      targetDir;
     StringArray     allSources;