MinGW kullanıyorum. Malloc ve diğer birkaç genel işlevini çağıran bir kodum var. Yazdığımda:MinGW undefined başvuru malloc, ücretsiz, sprintf, _beginthreadex
gcc TestCode.c
Bir a.exe dosyası alıyorum, mükemmel çalışıyor ve herhangi bir uyarı almıyorum. Bunu yazarsanız
:
TestCode.o:TestCode.c:(.text+0xa): undefined reference to `__main'
TestCode.o:TestCode:(.text+0x2e): undefined reference to `printf'
TestCode.o:TestCode:(.text+0x42): undefined reference to `_strerror'
TestCode.o:TestCode:(.text+0x69): undefined reference to `snprintf'
TestCode.o:TestCode:(.text+0x7e): undefined reference to `malloc'
TestCode.o:TestCode:(.text+0x93): undefined reference to `_strerror'
TestCode.o:TestCode:(.text+0xb1): undefined reference to `sprintf'
TestCode.o:TestCode:(.text+0xcf): undefined reference to `free'
Biliyorum bu bağlayıcı çağırıyorum nasıl bir sorun olduğunu tahmin ediyorum:
gcc -c TestCode.c -o TestCode.o
ld *.o
ben gibi uyarılar bir sürü olsun. Bu nedenle, yalnızca sorunun ne olduğu net değilse kodu yayınlayacağım. Ben bu kolay bir düzeltme olduğunu ve sadece bağlantı yaparken bazı süper açık kütüphane dahil etmeyi unuttuğumu umuyorum.
olası yinelemesi [MinGW derleyicisini kullanırken bağlantı hatası (bulamıyorum __main)] (http://stackoverflow.com/questions/4981826/link-error-while-using-mingw-compiler-cant-find- ana) –