Jump to content
  • Advertisement
Sign in to follow this  
ak11streetballer

How do I fix a linker error?

This topic is 3756 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys, I was making my first Direct X program to display a blue screen. After coding it completely, it complied without any errors. But when I wanted VC++ to build an EXE file for me it threw up an error saying - Linking... C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (AUGUST 2007)\LIB\X64\d3d9.lib : fatal error LNK1113: invalid machine type Error executing link.exe. My EXE file isnt getting created. How do I fix this? Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Are you sure you want to be linking against the x64 library? Note the "lib\x64" in the path. Try switching to the "lib\x86" folder for your VC++ path.

Share this post


Link to post
Share on other sites
Ok I changed that to X86 and I got 2 linker errors now...

Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/abhi.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

Any ideas?

Share this post


Link to post
Share on other sites
Well I managed to correct that error. Now I have a new error coming up -

Linking...
LINK : fatal error LNK1181: cannot open input file "d3d9.lib"
Error executing link.exe

How do I fix this now?

Share this post


Link to post
Share on other sites
What version of Visual Studio are you using? Did you set up the DirectX SDK paths correctly, or did you just add the full path to d3d9.lib to your linker options?

Share this post


Link to post
Share on other sites
You need to link the library files (there is no comma! between files) d3dxof.lib dxguid.lib d3d9.lib d3dx9.lib winmm.lib into your project. Go to Project/Property Pages/Linker/Input/Additional Dependencies and just type in. In addition, you need to change character set. Go to Project/Property Pages/ Configuration Properties/General/Character Set and make Use Multi-byte Character Set.

Share this post


Link to post
Share on other sites
Well I havent been able able to find the character set option. I use Visual C++ 6.0

I am getting the same error again...

LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/abhi.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

This is so damn irritating. I spend so much of time coding those huge DirectX codes only to end up with this stupid error! URGENT HELP NEEDED for a frustrated programmer! :(

Share this post


Link to post
Share on other sites
Doesn't that error indicate you created your project as a Win32 console application, but provided a WinMain() instead of a main(), for example?

Share this post


Link to post
Share on other sites
In your VC property page, select configuration properties->linker->input, and in the field provided for "Ignore specific library", put libcd.lib

Share this post


Link to post
Share on other sites
Quote:

LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/abhi.exe : fatal error LNK1120: 1 unresolved externals

This means that the linker is looking for a routine to execute (_main, which is main() in C) It has been externally declared, but the linker cannot find its definition.

This is normally defined by the programmer - you. However, in Win32 applications, this entry point is _WinMain instead of _main. - This is where I suspect the problem is at.

Most DirectX programs that I have seen are written for Win32 applications (These use _WinMain) and not Win32 console projects (Default. These use _main), so I second Neverender's suggestion here.

I dont use Visual C++ 6.0, so cannot help you much there.

I do recommend upgrading to a Visual C++ Express Edition (Either 2005 or 2008 version) as Visual C++ 6.0 is both old and not very compilent with C99. Also, Visual C++ 6 has been known to have alot of problems with it.

Also, try to learn more about the linker and linking errors. It will help in understanding the errors and linking problems that you may encounter.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!