Author Topic: DirextX and Code::Blocks  (Read 6084 times)

Offline Dark_Phoenix

  • Multiple posting newcomer
  • *
  • Posts: 11
DirextX and Code::Blocks
« on: June 16, 2007, 04:34:54 pm »
Hello...
I just now started using Code::Blocks, and so far I like it, but I am having problems compiling DirectX applications.  Here is my build log
Code
d3dx9.lib(cpudetect.obj):: error LNK2019: unresolved external symbol __imp__RegCloseKey@4 referenced in function "int __stdcall GetD3DRegValue(unsigned long,char *,void *,unsigned long)" (?GetD3DRegValue@@YGHKPADPAXK@Z)
d3dx9.lib(d3dx9dbg.obj):: error LNK2001: unresolved external symbol __imp__RegCloseKey@4
d3dx9.lib(cpudetect.obj):: error LNK2019: unresolved external symbol __imp__RegQueryValueExA@24 referenced in function "int __stdcall GetD3DRegValue(unsigned long,char *,void *,unsigned long)" (?GetD3DRegValue@@YGHKPADPAXK@Z)
d3dx9.lib(d3dx9dbg.obj):: error LNK2019: unresolved external symbol __imp__RegQueryValueExA@24 referenced in function "int __stdcall GetD3DRegValue(unsigned long,char *,void *,unsigned long)" (?GetD3DRegValue@@YGHKPADPAXK@Z)
d3dx9.lib(cpudetect.obj):: error LNK2019: unresolved external symbol __imp__RegOpenKeyA@12 referenced in function "int __stdcall GetD3DRegValue(unsigned long,char *,void *,unsigned long)" (?GetD3DRegValue@@YGHKPADPAXK@Z)
d3dx9.lib(d3dx9dbg.obj):: error LNK2001: unresolved external symbol __imp__RegOpenKeyA@12
bin\Debug\DirectInputCB.exe:: fatal error LNK1120: 3 unresolved externals
:: === Build finished: 7 errors, 0 warnings ===
I currently have the 061007 build of C::B, and am using the MS VC toolkit 2003.  I have the search directories set up for MSVC toolkit, the platform SDK and the DX SDK, and I have all the libraries listed in my linker options -  d3d9, d3dx9, dxguid, dinput8, user32, winmm, and gdi32.
Not sure what I am missing here.  I am guessing that there is a library that I need that is not linking but I am not sure.  This has left me a bit confused as I have compiled this exact app with the same linker options successfully in dev-c++.  

Any ideas?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: DirextX and Code::Blocks
« Reply #1 on: June 16, 2007, 04:42:37 pm »
This has left me a bit confused as I have compiled this exact app with the same linker options successfully in dev-c++. 
You need to link against advapi32. Make sure this lib is added in the project's linker settings.
(BTW: I would swear the DevCpp has that option - otherwise linking would fail there, too.)
With regards, Morten.

Ps.: BTW: You can consult the MSDN easily for Win32API to find out which libs you need to link against.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Dark_Phoenix

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: DirextX and Code::Blocks
« Reply #2 on: June 17, 2007, 03:26:15 pm »
OK, I am still at a loss here.  I have the advapi32 lib listed in the linker settings and the dll is in my system directory.  The lib file is actually in both the c::b/lib and the MSPlatformSDK/lib directories, could there be a conflict here since I have both of those set up in my search directories?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: DirextX and Code::Blocks
« Reply #3 on: June 17, 2007, 03:34:16 pm »
could there be a conflict here since I have both of those set up in my search directories?
Sure. You shouldn't do that. At some point you have to decide what compiler you choose: MinGW or a MS one. For the MinGW you need to use the MinGW Win32API files and libs (provided at Mingw.org), for MS compiler you better use the platform SDK. There is (however) a way to combine both worlds but why do so? You have the core (API) libs of WinAPI for both - so it's better you stay consistent. There is (BTW) also a Direct/X DevPak especially for MinGW... google for it. If you want to stick with VS2003 - kick out the MinGW "addons".
With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Dark_Phoenix

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: DirextX and Code::Blocks
« Reply #4 on: June 17, 2007, 03:44:46 pm »
Quote
If you want to stick with VS2003 - kick out the MinGW "addons".
VS2003 is what I want to use here.  I have always used minGW with dev-c++ and the DX devpak but that is kind of a pain so I am looking into c::b to do my DX programming.  Those files and directories were set up automatically by c::b and the platform sdk.  So if I want to stick with VS2003 which lib should I use, the one in the platform sdk/lib directory or the one from c::b?

btw, if it matters.... I have c::b set up to use the VC2003 compiler
« Last Edit: June 17, 2007, 03:46:44 pm by Dark_Phoenix »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: DirextX and Code::Blocks
« Reply #5 on: June 17, 2007, 03:53:01 pm »
So if I want to stick with VS2003 which lib should I use, the one in the platform sdk/lib directory or the one from c::b?
My suggestion:
- install Code::Blocks *only* (without compiler - e.g. a nightly)
- install the MinGW compiler/libs/includes in a separate directory
- install any DevPak's in another separate directory
- install the MSVC 2003 compiler/libs/includes in a separate directory
- install the MS platform SDK and Direct/X SDK in another 2 separate directories
- in C::B: setup the MinGW compiler to point to the MinGW compiler suite (optionally including DevPak folders)
- in C::B: setup the MSVC compiler to point to the MSVC 2003 compiler suite (optionally including platform and Direct/X SDK)

Having done this you should be able to have a clean setup and compilation for either MinGW or MSVC 2003. No mixed folders anymore.
With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Dark_Phoenix

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: DirextX and Code::Blocks
« Reply #6 on: June 17, 2007, 05:07:24 pm »
OK, so everything is already set up like you suggested and it still comes up with thoses unresolved externals.  But after some further investigation I have discovered that it works just fine when I have the vuild target set to release.  I only get those errors when it is set to debug.

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: DirextX and Code::Blocks
« Reply #7 on: June 17, 2007, 06:09:55 pm »
MS compilers are sissy about Debug and Release libraries as they are linked against different CRTs. I believe there should be some Debug lib of DirectX which will allow you to compile in Debug mode.
Be a part of the solution, not a part of the problem.

Offline Albenejean

  • Multiple posting newcomer
  • *
  • Posts: 65
Re: DirextX and Code::Blocks
« Reply #8 on: June 18, 2007, 03:01:01 pm »
OK, so everything is already set up like you suggested and it still comes up with thoses unresolved externals.  But after some further investigation I have discovered that it works just fine when I have the vuild target set to release.  I only get those errors when it is set to debug.

Make sure that your debug config is OK...
For those libs, I set them in the general options, and not in the debug or release options.

Quote
I believe there should be some Debug lib of DirectX
Yes they are d3dx9d.lib, d3d9d.lib, ... . But I prefer using the DirectX Control Panel.