Hello, I wrote a very simple openGL application, as below #include #include int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutCreateWindow("red 3D lighted cube"); printf("GL_VERSION = %s\n",glGetString(GL_VERSION) ); return 0; } Compiling it with Clang and adding -lglut option worked correctly $ clang simple.c -o simple -lglut $ ./simple GL_VERSION = 2.1 Mesa 7.10.2 But, adding the -emit-llvm option to clang, does not work as below $ clang -O3 -emit-llvm simple.c -o simple.bc -lglut /usr/bin/ld: /usr/local/bin/../lib/LLVMgold.so: error loading plugin /usr/bin/ld: /usr/local/bin/../lib/LLVMgold.so: error in plugin cleanup (ignored) clang: error: linker command failed with exit code 1 (use -v to see invocation) Also, removing the -lglut option worked with clang but failed with lli as below $ clang -O3 -emit-llvm simple.c -c -o simple.bc $ lli simple.bc LLVM ERROR: Program used external function 'glutInit' which could not be resolved! Please advice how to run it using the llvm jit 'lli' Thanks in advance Sara Une messagerie gratuite, garantie à vie et des services en plus, ça vous tente ? Je crée ma boîte mail www.laposte.net -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130126/71730723/attachment.html>
Hi,> But, adding the -emit-llvm option to clang, does not work as below > $ clang -O3 -emit-llvm simple.c -o simple.bc -lglut > /usr/bin/ld: /usr/local/bin/../lib/LLVMgold.so: error loading plugin > /usr/bin/ld: /usr/local/bin/../lib/LLVMgold.so: error in plugin cleanup (ignored) > clang: error: linker command failed with exit code 1 (use -v to see invocation)What Clang is actually trying to do here is generate a .bc (LLVM IR) file and feed that into the linker to produce a final fully native output (which you happen to have decided should be called simple.bc -- it's still going to be an ELF file). Since linkers don't natively understand LLVM's IR, this needs a plugin which calls back to LLVM for some of the work. That's the LLVMgold.so plugin it's referring to. My guess is that it doesn't exist on your machine; compiling it would require extra effort. If you want a .bc containing LLVM IR, give clang the "-c" ("compile only") option (and not -lglut, though it'll be harmless). Then it won't bother trying to link.> Also, removing the -lglut option worked with clang but failed with lli as below > $ clang -O3 -emit-llvm simple.c -c -o simple.bc > $ lli simple.bc > LLVM ERROR: Program used external function 'glutInit' which could not be resolved! > > Please advice how to run it using the llvm jit 'lli'The problem here is that lli looks inside its own dynamic context for functions referenced externally. I couldn't see an option to lli which will make it load a specified dynamic library. Someone else may reply with one I've missed of course. I suppose if you were creating your own JIT compiler you'd want to handle that yourself anyway. A hack that worked for me was to tell the system itself to load the required library, rather than lli: $ LD_PRELOAD=/usr/lib/libglut.so lli -use-mcjit simple.bc Hope this helps. Tim.
Possibly Parallel Threads
- [LLVMdev] Testing canaries
- No window decorations for simple glut app on compiz/aiglx?
- [LLVMdev] Segfault when using llvm-3.6 and OpenGL at the same time on Linux (with mesa, which uses llvm-3.4)
- OpenGL support on wine 0.9.21 in Fedora Core 5
- [LLVMdev] llvm-gcc-4.2 and -O4