I am looking to develop a d3d11 app with gcc from tdm-gcc(tried pure MinGW didn't work), I've written test app, but am unable to link libd3d11 in order to get D3D11CreateDeviceAndSwapChain#48
The app is supposed to be compileable in both 32-bit and 64-bit respectively.
Here's how I compile trying to use mingw headers and libs:
gcc -m32 -ld3d11 main.c -o test.exe
I am getting:
C:/MinGW/64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:\TEMP\ccvsC3nh.o:main.c:(.text+0x243): undefined reference to `D3D11CreateDeviceAndSwapChain#48'
collect2.exe: error: ld returned 1 exit status
I've seen some posts about compiling directx via mingw, but they didn't give sufficient info, as I am not exactly sure what I am missing or doing wrong.
Related
I'm trying to compile an example C program that links against PortAudio for a MIPSEL OpenWRT architecture targeting the MT7688 chip.
My starting point is this 351MB Docker image that has a working MIPSEL GNU uclibc toolchain (run source env.sh to set environment variables).
I tried to cross-compile PortAudio at first, but I couldn't get it to output MIPS binaries despite configuring Makefile for --host=mips-openwrt-linux-uclibc. So I copied working libasound.so.2, libportaudio.so.2 and libportaudio.so.2 files from my MIPS device and placed them in both the source folder and /usr/lib, then passed explicit include and linker paths:
$CC I/snowboy/examples/C/portaudio/install/include -L/usr/lib -lasound demo.c -o demo -v
> /bin/ld: cannot find -lasound
collect2: error: ld returned 1 exit status
No dice. I am too dumb to understand GCC linker paths, but I've come this far. Can anyone help me to navigate this cross-compilation minefield?
I'm a beginner of programming. I am using Eclipse CDT for C programming. When I build any program, the console window shows the below message. Please tell me a specific way so that I could solve this problem.
Console window:
Info: Configuration "Debug" uses tool-chain "MinGW GCC" that is unsupported on this system, attempting to build anyway.
Info: Internal Builder is used for build
gcc -O0 -g3 -Wall -c -fmessage-length=0 -o test.o "..\\test.c"
gcc -o test.exe test.o
c:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.9.2/../../../../i686-pc-mingw32/bin/ld.exe: cannot open output file test.exe: Permission denied
collect2.exe: error: ld returned 1 exit status
00:33:35 Build Finished (took 2s.385ms)
USUALLY(in my experience), LD errors result from you not including the libraries or linkers necessary. Go to your project, right click, select properties, under C build go to settings, GCC C compiler and includes and add the libraries.
Your operating system simply does not allow to modify a file while it is in use, so the compilation fails, because compiler can't remove the old executable and place a new one. To solve this, simply restart eclipse program.
I am trying to compile apache2 with LLVM, to generate final binaries in LLVM IR.
I used flto option in compiling and linking and passed "also-emit-llvm" to the linker through clang.
It seems to work for most steps, however I had two concerns
1) Earlier I used LLVM 3.6, whose gold plugin doesn't accept also-emit-llvm, but has emit-llvm only, basically it will emit only elf or llvm. Which the Autotools build system doesn't like. The configure and make script want binaries, while I want llvm. Any solutions to this?
2) So I shifted to LLVM 3.5.2, the build process goes well, I can generate both httpd.bc and httpd elf binaries, but the linker doesn't want to link for modules (it was able to link for binaries)
Specifically, I get this error
`
/usr/share/apr-1.0/build/libtool --silent --mode=link /home/rbhatia/Desktop/llvm-newbuild/bin/clang -pthread -flto -o mod_authn_file.la -rpath /home/rbhatia/Desktop/httpd-2.4.12/llvm/modules -module -avoid-version mod_authn_file.lo
/usr/bin/ld: error: .libs/mod_authn_file.o:1:3: invalid chaenter code hereracter
/usr/bin/ld: error: .libs/mod_authn_file.o:1:3: syntax error, unexpected $end
/usr/bin/ld: error: .libs/mod_authn_file.o: not an object or archive
collect2: error: ld returned 1 exit status
`
I can see that mod_authn_file.o is a valid LLVM IR file which I can disassemble with llvm-dis.
Also, just before this step, the linker is able to link httpd and httpd.bc
Any help on what the error is?
Take a look at
https://github.com/SRI-CSL/whole-program-llvm
we use this tool to build quite large projects into bitcode. Our
biggest so far was FreeBSD 10.0, so size is not usually an issue.
Our travis build check is actually
apache, as is our tutorial. Hope that helps.
I tried to compile tcc for ARM using gcc 4.6.3 . but I got following error while compiling in both shared/static lib mod :
root#localhost:/p/tcc/tcc# make
gcc -o tcc tcc.o libtcc.so.1.0 -lm -ldl -Wall -g -O2 -fno-strict-aliasing -Wno-pointer-sign -Wno-sign-compare -D_FORTIFY_SOURCE=0 -Wl,-rpath,"/usr/local/lib" libtcc.so.1.0: undefined reference to `vrotb'
collect2: ld returned 1 exit status
make: *** [tcc] Error 1
I am using lastest branch from tcc github
Just checked it on raspberry pi (ARMv6 CPU). https://github.com/TinyCC/TinyCC repository, removed static qualifier from vrotb function in tccgen.c (line 945). It builds and passes 'hello world'.
Since that's obvious mistake likely to be introduced by some change that they forgot to adapt for ARM - i suggest performing further tests to ensure it works as intended. Bug report should be filed - probably on github.
I know it is little confusing, but your problem is that you are using wrong repository. Fabrice Bellard does not work any more on TinyCC (see http://bellard.org/tcc/). He keeps his repositories for personal/historical reasons. However all development has moved to http://repo.or.cz/w/tinycc.git. To confuse things even more the 0.9.26 release from Fabrice's web site is actually from the http://repo.or.cz/w/tinycc.git repository, and not Fabrice's own. But this is all just communication issue. In short you should use new repository. On the repository web site is a link to a mailing list where you should report any problems in case the new repo code does not compile.
I want to link an existing shared library (FlashRuntimeExtensions.so) to my C-code while compiling my own shared library. But whatever I try I always get the same error; that the file is in a wrong format. Does anybody have an idea on how to solve this?
Here is my compile command:
$ g++ -Wall ane.c FlashRuntimeExtensions.so -o aneObject
FlashRuntimeExtensions.so: could not read symbols: File in wrong format
collect2: ld gaf exit-status 1 terug
Your command line tries to generate x86 code and link it to ARM code using the native g++ available in your distribution.
This will not work. Use the Android NDK available here: http://developer.android.com/tools/sdk/ndk/index.html
The NDK includes a set of cross-toolchains (compilers, linkers, etc..) that can generate native ARM binaries on Linux, OS X, and Windows (with Cygwin) platforms.
In general .so will be linked using -l.
for example, pthread -lpthread we use.
gcc sample.c -o myoutput -lpthread
But as per #chill's statement, what you are doing in command is correct only.
I suggest you to refer the following link.
C++ Linker Error SDL Image - could not read symbols
It should be an architecture mismatch. I faced this problem once, I have solved it by building the libs in same target platform and it is obvious. If you are using linux or Unix like OS you can see that by file command and if you are using windows you can see that using Dependency Walker. You need to make sure that all the libs matches architecture.