Author Topic: Using DirectX with Code::Blocks  (Read 37452 times)

Offline antonien

  • Multiple posting newcomer
  • *
  • Posts: 24
Using DirectX with Code::Blocks
« on: January 25, 2011, 09:20:25 pm »
Hi everybody

I made a search on the forum but couldn't find a definite answer to my question.
May I use DirectX with Code::Blocks as it is (i.e with MinGW as compiler) or do I have to change for another compiler (some Microsoft stuff) ?
If I have to, is there a comprehensive tutorial which explains how to do it ?
I am not very familiar with installation (actually I am panicked when I have to do this kind of stuff). Do I have to uninstall Code::Blocks to do it ?
Is there a difference of behaviour between a program compiled with MinGW and the same program compiled with another compiler ?

Thanks for the answer if any.

Best Regards.
antonien

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Using DirectX with Code::Blocks
« Reply #1 on: January 25, 2011, 09:53:34 pm »
May I use DirectX with Code::Blocks as it is (i.e with MinGW as compiler) or do I have to change for another compiler (some Microsoft stuff) ?
The Direct/X SDK works perfectly with MinGW. All you need to do is the usual setup. First install the SDK itself, then use e.g. the Direct/X wizard of C::B to get yourself an example project stub and go ahead.
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 antonien

  • Multiple posting newcomer
  • *
  • Posts: 24
Re: Using DirectX with Code::Blocks
« Reply #2 on: January 25, 2011, 10:14:39 pm »
Thanks a lot for your quick answer. I read that I had to use some utility to convert the .lib files and that was enough for me to be upset.
I'll try the Direct/X wizard.
I use also wxWidgets (and I like it !). I guess I'll have to do some stuff to combine both : there is no wizard to make it for me...

Thanks again, I feel more comfortable.
Regards

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Using DirectX with Code::Blocks
« Reply #3 on: January 26, 2011, 07:51:17 am »
Thanks a lot for your quick answer. I read that I had to use some utility to convert the .lib files and that was enough for me to be upset.
There is no need for any conversion. MinGW can handle the windows library files (*.lib) just fine!

BTW: No, we don't have a wizard for each and every combination (;-)). However, there is plenty code around at "the Google" which combines Direct/X with wxWidgets as a starter...
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 stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Using DirectX with Code::Blocks
« Reply #4 on: January 26, 2011, 02:07:16 pm »
There is no need for any conversion. MinGW can handle the windows library files (*.lib) just fine!

When did this happen?
I know MinGW can handle C DLLs.

The old link I used to post for MinGW DirectX Library
http://mamedev.org/tools/previous-20070810.html

The new link
http://mamedev.org/tools/

Tim S.
« Last Edit: January 26, 2011, 02:10:50 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Using DirectX with Code::Blocks
« Reply #5 on: January 26, 2011, 06:03:11 pm »
There is no need for any conversion. MinGW can handle the windows library files (*.lib) just fine!
When did this happen?
I don't know, but I am doing this a lot at work. All direct/x related apps are linked against the MS SDK without issues.

I wasn't aware that this was not possible earlier... :shock: Probably the functions I am using are MinGW friendly in the first place... (well I did modify some of the header myself though...)
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 stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Using DirectX with Code::Blocks
« Reply #6 on: January 26, 2011, 07:35:45 pm »
Hi everybody

Is there a difference of behaviour between a program compiled with MinGW and the same program compiled with another compiler ?


Yes, if the programmer is not doing his/her job right; And sometimes yes, if the program is using complex library that has different support between compilers.

C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline antonien

  • Multiple posting newcomer
  • *
  • Posts: 24
Re: Using DirectX with Code::Blocks
« Reply #7 on: January 26, 2011, 09:50:24 pm »
I am progressing slowly. I used the DirectX wizard, I replaced <strsafe.h> by <cstddef> as advised somewhere else, I removed the "L" before any string to make it compile... and linking failed :

mingw32-g++.exe -LC:\CodeBlocks\DirectX\lib  -o bin\Debug\Directxtest.exe obj\Debug\main.o    -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 -ld3d9 -ld3dx9 C:\CodeBlocks\DirectX\Lib\x64\d3dx9.lib
c:/codeblocks/mingw/bin/../lib/gcc/mingw32/4.4.1/../../../../mingw32/bin/ld.exe: cannot find -ld3dx9
What's that ?
d3dx9.lib is sitting in the lib directory and this directory is made available to the linker.

Any idea of what happens ?

Thanks in advance.

Offline ironhead

  • Almost regular
  • **
  • Posts: 210
Re: Using DirectX with Code::Blocks
« Reply #8 on: January 27, 2011, 12:43:22 pm »
I am going to assume this was all one line (i.e. the d3dx9.lib reference was at the end of the line):

mingw32-g++.exe -LC:\CodeBlocks\DirectX\lib  -o bin\Debug\Directxtest.exe obj\Debug\main.o    -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 -ld3d9 -ld3dx9 C:\CodeBlocks\DirectX\Lib\x64\d3dx9.lib

The '-ld3dx9' isn't required if you are passing in d3dx9.lib, in fact it's causing this error:

c:/codeblocks/mingw/bin/../lib/gcc/mingw32/4.4.1/../../../../mingw32/bin/ld.exe: cannot find -ld3dx9

Because MinGW is looking for libd3dx9.a.  You can drop -LC:\CodeBlocks\DirectX\lib if you are passing in the absolute path of the library.

Offline antonien

  • Multiple posting newcomer
  • *
  • Posts: 24
Re: Using DirectX with Code::Blocks
« Reply #9 on: January 27, 2011, 09:22:25 pm »
Thanks for the answer : I did remove d3dx9 from the linker settings (actually, I didn't know it was there : it's the wizard who did that for me).

Next stop : winmain@16

Undefined reference to WinMain@16 !
Couldn't find any reference to that WinMain@16...

I am getting fed up with MinGW...

If anybody has a cue, I'll be gratefull.

Best regards

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Using DirectX with Code::Blocks
« Reply #10 on: January 28, 2011, 01:15:43 am »
Learn to use Google; this thread needs to be locked because it is no longer a topic valid for this site!
http://mingw-starter.blogspot.com/2008/02/mingw-sdl.html

Tim S.
« Last Edit: January 28, 2011, 03:08:52 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline pixelpuffin

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Using DirectX with Code::Blocks
« Reply #11 on: November 13, 2013, 09:41:16 pm »
i had the same problem with d3dx9
how did you remove it from the linker
sorry if this is a stupid question im a bit new

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Using DirectX with Code::Blocks
« Reply #12 on: November 13, 2013, 10:10:20 pm »
Project->Build Options->Linker settings

Offline pixelpuffin

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Using DirectX with Code::Blocks
« Reply #13 on: November 13, 2013, 10:38:39 pm »
theres nothing in linker settings though

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Using DirectX with Code::Blocks
« Reply #14 on: November 13, 2013, 10:42:46 pm »
probably you have to mark the project name target:
Project->Build Options->Linker settings-> The project name on the left
greetings