Note that there are some explanatory texts on larger screens.

plurals
  1. POBuild shared library with Clang++
    text
    copied!<p>I am trying to build a shared library (dll for Windows) using Clang++.</p> <p>I have run the following commands:</p> <pre><code>clang++ -c -o hello.o hello.cpp clang++ -shared -v -o hello.dll hello.o </code></pre> <p>The first command works fine but when I try to build the dll I get this error:</p> <pre><code>clang version 3.2 (tags/RELEASE_32/final) Target: i686-pc-mingw32 Thread model: posix "c:/MinGW/bin/g++.exe" -shared -v -m32 -o worker.dll worker.o Using built-in specs. COLLECT_GCC=c:/MinGW/bin/g++.exe COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.6.2/lto-wrapper.exe Target: mingw32 Configured with: ../gcc-4.6.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --build=mingw32 --prefix=/mingw Thread model: win32 gcc version 4.6.2 (GCC) COMPILER_PATH=c:/mingw/bin/../libexec/gcc/mingw32/4.6.2/;c:/mingw/bin/../libexec/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ LIBRARY_PATH=c:/mingw/bin/../lib/gcc/mingw32/4.6.2/;c:/mingw/bin/../lib/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/lib/;c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../;/mingw/lib/ COLLECT_GCC_OPTIONS='-shared' '-v' '-m32' '-o' 'worker.dll' '-shared-libgcc' '-mtune=i386' '-march=i386' c:/mingw/bin/../libexec/gcc/mingw32/4.6.2/collect2.exe --shared -Bdynamic -e _DllMainCRTStartup@12 --enable-auto-image-base -u ___register_frame_info -u ___deregister_frame_info -o worker.dll c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../dllcrt2.o c:/mingw/bin/../lib/gcc/mingw32/4.6.2/crtbegin.o -Lc:/mingw/bin/../lib/gcc/mingw32/4.6.2 -Lc:/mingw/bin/../lib/gcc -Lc:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/lib -Lc:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../.. -L/mingw/lib worker.o -lstdc++ -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt c:/mingw/bin/../lib/gcc/mingw32/4.6.2/crtend.o Cannot export _hello: symbol not found collect2: ld returned 1 exit status clang++: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation) </code></pre> <p>Here is the file I am compiling:</p> <pre><code>// hello.cpp #include &lt;iostream&gt; #if defined(_WIN32) #define LIBRARY_API __declspec(dllexport) #else #define LIBRARY_API #endif extern "C" void LIBRARY_API hello(); void hello() { std::cout &lt;&lt; "Hello, World!" &lt;&lt; std::endl; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload