News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

Using DirectX with Code::Blocks

Started by antonien, January 25, 2011, 09:20:25 PM

Previous topic - Next topic

antonien

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

MortenMacFly

Quote from: antonien on January 25, 2011, 09:20:25 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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

antonien

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

MortenMacFly

Quote from: antonien 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.
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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

stahta01

#4
Quote from: MortenMacFly on January 26, 2011, 07:51:17 AM
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.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

MortenMacFly

Quote from: stahta01 on January 26, 2011, 02:07:16 PM
Quote from: MortenMacFly on January 26, 2011, 07:51:17 AM
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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

stahta01

Quote from: antonien on January 25, 2011, 09:20:25 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++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

antonien

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.

ironhead

I am going to assume this was all one line (i.e. the d3dx9.lib reference was at the end of the line):

Quote from: antonien on January 26, 2011, 09:50:24 PM
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:

Quote from: antonien on January 26, 2011, 09:50:24 PMc:/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.

antonien

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

stahta01

#10
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.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

pixelpuffin

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

BlueHazzard

Project->Build Options->Linker settings

pixelpuffin

theres nothing in linker settings though

BlueHazzard

probably you have to mark the project name target:
Project->Build Options->Linker settings-> The project name on the left
greetings