Author Topic: DirectX 8 & 9  (Read 10944 times)

MrTAToad

  • Guest
DirectX 8 & 9
« on: September 06, 2005, 01:04:05 pm »
Hello

Is it possible to somehow use DirectX 8 & 9 with Code::Blocks.  The problem is the VS Toolkit compiler doesn't come with the D3D8x lirbrary files or headers.  Unfortunately downloading the DX8 SDK doesn't help as a) it complains about LIBC (and various windows libraries), and if they are ignored, then you get errors complaining about various STL errors (for some reason) - I'll add the exact error messages when I get home.

Using VS7 headers and libraries, and all is fine of course - unfortunately its not exactly legal to use those instead of the Platform SDK.

I'm trying to get DarkSDK (up and running with said editor - works fine in VS 2003).  Unfortunately to complicate matters the multiplayer system is DX8 and the rest is DX9- hence the reason why both versions of DirectX are needed.



Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: DirectX 8 & 9
« Reply #1 on: September 06, 2005, 05:43:02 pm »
What "complaints" about the libc?

It seems to me that you're using the wrong headers / libraries at some point... maybe (MAYBE) you got mixed the included MINGW c headers...
(But then again, i'm no VC expert, since all my compiling is done using mingw...)

MrTAToad

  • Guest
Re: DirectX 8 & 9
« Reply #2 on: September 06, 2005, 07:44:12 pm »
Not using MINGW - its Microsoft all the way...

However, you are correct in that the libraries are the problem - unfortunately the DX8 headers & libraries in VS 2003 are different from those in the SDK, and whilst the former ones work fine, the latter dont.

Which would be no problem if it was legal to distribute said headers and libraries...  Which its not :(

Unfortunately I cant put the errors here as my Mums using my machine - hopefully it can be done either later or tomorrow - if not Ill have to wait a week.

grv575

  • Guest
Re: DirectX 8 & 9
« Reply #3 on: September 06, 2005, 10:15:04 pm »
Well do post the errors (make sure you set the option to show the full commandline too).  I've worked out most vc++ issues with compiling things and you can sometimes even build a missing .lib file.  See the wiki: http://wiki.codeblocks.org/index.php/FAQ#I_can.27t_compile_a_multithreaded_app_with_VC_Toolkit.21_Where_are_the_libraries.3F
as well for libraries which you need to consider when using vc++ toolkit.  I don't know if there are actually some things that won't compile or no.  I tried compiling WinMerge cvs (and the msvc importer worked great :) ) and the only thing I couldn't get past was not having mfc42s.lib or something -- it looks like for the handhelp (CE) version of MFC they split the runtime dll up, but not so for the desktop version.  WinMerge was still compiling against this CE "helper" lib which I couldn't figure out why, and it wouldn't link without it either.  So it is possible that some things might be missing but I've heard positive things about getting directx working with just the vc++ toolkit.

MrTAToad

  • Guest
Re: DirectX 8 & 9
« Reply #4 on: September 06, 2005, 11:02:05 pm »
The compiler reports thus :

Project   : Win32 Application
Compiler  : Microsoft Visual C++ Toolkit 2003 (called directly)
Directory : C:\Documents and Settings\Jacky\My Documents\
--------------------------------------------------------------------------------
Switching to target: default
link.exe /nologo /subsystem:windows    /LIBPATH:"C:\Program Files\Microsoft DirectX 9.0 SDK (August 2005)\Lib\x86" /LIBPATH:"C:\Program Files\Microsoft Platform SDK\Lib" /LIBPATH:"C:\Program Files\The Game Creators\Dark Game SDK - FREEWARE Edition\Lib\VS7" /LIBPATH:"C:\Program Files\Microsoft Visual C++ Toolkit 2003\lib" /LIBPATH:"C:\Documents and Settings\Jacky\Local Settings\Temp\DXF\DXSDK\lib" /out:"C:\Documents and Settings\Jacky\My Documents\Win32GUI.exe"   gdi32.lib user32.lib kernel32.lib  .objs\main.obj     
basic3D.lib(ProcessHSR.obj) : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ)
convx.lib(ConvX.obj) : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ)
convmd3.lib(ConvMD3.obj) : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ)
convmdl.lib(ConvMDL.obj) : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ)
basic3D.lib(CCompiler.obj) : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ)
basic3D.lib(NVMeshMenderD3DX.obj) : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ)
world.lib(Patch.obj) : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ)
multiplayer.lib(CNetwork.obj) : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ)
system.lib(dxdiaginfo.obj) : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ)
basic3D.lib(Universe.obj) : error LNK2019: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ) referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::erase(unsigned int,unsigned int)" (?erase@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@II@Z)
basic3D.lib(DBOFormat.obj) : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ)
basic3D.lib(cLightMaps.obj) : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ)
basic3D.lib(CBSPTree.obj) : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ)
basic3D.lib(ProcessHSR.obj) : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xlen(void)const " (?_Xlen@_String_base@std@@QBEXXZ)
convx.lib(ConvX.obj) : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xlen(void)const " (?_Xlen@_String_base@std@@QBEXXZ)
convmd3.lib(ConvMD3.obj) : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xlen(void)const " (?_Xlen@_String_base@std@@QBEXXZ)
convmdl.lib(ConvMDL.obj) : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xlen(void)const " (?_Xlen@_String_base@std@@QBEXXZ)
basic3D.lib(CCompiler.obj) : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xlen(void)const " (?_Xlen@_String_base@std@@QBEXXZ)
basic3D.lib(NVMeshMenderD3DX.obj) : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xlen(void)const " (?_Xlen@_String_base@std@@QBEXXZ)
world.lib(Patch.obj) : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xlen(void)const " (?_Xlen@_String_base@std@@QBEXXZ)
multiplayer.lib(CNetwork.obj) : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xlen(void)const " (?_Xlen@_String_base@std@@QBEXXZ)
system.lib(dxdiaginfo.obj) : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xlen(void)const " (?_Xlen@_String_base@std@@QBEXXZ)
basic3D.lib(Universe.obj) : error LNK2019: unresolved external symbol "public: void __thiscall std::_String_base::_Xlen(void)const " (?_Xlen@_String_base@std@@QBEXXZ) referenced in function "protected: bool __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Grow(unsigned int,bool)" (?_Grow@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IAE_NI_N@Z)
basic3D.lib(DBOFormat.obj) : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xlen(void)const " (?_Xlen@_String_base@std@@QBEXXZ)
basic3D.lib(cLightMaps.obj) : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xlen(void)const " (?_Xlen@_String_base@std@@QBEXXZ)
basic3D.lib(CBSPTree.obj) : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xlen(void)const " (?_Xlen@_String_base@std@@QBEXXZ)
C:\Documents and Settings\Jacky\My Documents\Win32GUI.exe : fatal error LNK1120: 2 unresolved externals
Process terminated with status 1 (0 minutes, 1 seconds)

DXF is the path to DX8 SDK

As I said before everything is fine with VS 2003 headers and libraries (and there are differences between DX8 there and in the SDK), which is probably the problem (and/or the non-free libraries are needed).
« Last Edit: September 06, 2005, 11:04:57 pm by MrTAToad »

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: DirectX 8 & 9
« Reply #5 on: September 07, 2005, 12:04:06 am »
Have you tried linking to a different runtime DLL?
(like multithreaded/release, singlethreaded/release, etc)

Search the forum for the respective flags to use...
Be patient!
This bug will be fixed soon...

grv575

  • Guest
Re: DirectX 8 & 9
« Reply #6 on: September 07, 2005, 01:28:34 am »
yeah could you post one of the compile steps as well.  the flags determine which C++ library is linked against (e.g. like mandrav pointed out, you can choose under compiler settings which runtime is used, for example multithreaded runtime library will link against LIBCPMT.LIB ).  It looks like you're missing stuff from the std:: namespace, so symbols from the C++ runtime.

"The Dark Game SDK is available now. The freeware version costs $60 (€45 / £32)
while the Shareware version costs $200 (€150 / £100). ..."
heh.  alrighty.

There's tips about compiling darksdk on this page:
http://homepages.nildram.co.uk/~nickk/html/q___a.html

-----------

You know what also works sometimes when you're looking for imports...

Grab ultraedit (or something that does find in files recursively for a given directory... note windows find doesn't work.. windows find misses a lot of stuff when you do find in files for whatever reason ??? ).
Then do search->find in files
Find: Xlen@_String_base@std
In Files:
Directory: C:\WINDOWS\system32\
Search subdirectories = yes

Running that gives you:

Code
----------------------------------------
Find 'Xlen@_String_base@std' in 'C:\WINDOWS\system32\msvcp70.dll' :
C:\WINDOWS\system32\msvcp70.dll(2620): @?$ctype@G@std@@QBEGG@Z
Found 'Xlen@_String_base@std' 1 time(s).
----------------------------------------
Find 'Xlen@_String_base@std' in 'C:\WINDOWS\system32\msvcp71.dll' :
C:\WINDOWS\system32\msvcp71.dll(1528): shift@?$codecvt@GDH@std@@QBEHAAHPAD1AAPAD@Z
Found 'Xlen@_String_base@std' 1 time(s).
----------------------------------------
Find 'Xlen@_String_base@std' in 'C:\WINDOWS\system32\msvcp71d.dll' :
C:\WINDOWS\system32\msvcp71d.dll(2757): @std@@
Found 'Xlen@_String_base@std' 1 time(s).
Error reading file 'C:\WINDOWS\system32\config\default'!!!
Error reading file 'C:\WINDOWS\system32\config\default.LOG'!!!
Error reading file 'C:\WINDOWS\system32\config\SAM'!!!
Error reading file 'C:\WINDOWS\system32\config\SAM.LOG'!!!
Error reading file 'C:\WINDOWS\system32\config\SECURITY'!!!
Error reading file 'C:\WINDOWS\system32\config\SECURITY.LOG'!!!
Error reading file 'C:\WINDOWS\system32\config\software'!!!
Error reading file 'C:\WINDOWS\system32\config\software.LOG'!!!
Error reading file 'C:\WINDOWS\system32\config\system'!!!
Error reading file 'C:\WINDOWS\system32\config\system.LOG'!!!
Search complete, found 'Xlen@_String_base@std' 3 time(s). (3 files.)

If you then run dependency walker (platform sdk tools) on msvcp71.dll you should see you're symbols that you're missing.

So it looks like you may _need_ to link against msvcp71.dll (I haven't checked the static lib for the symbols but it may / may not work).  So try linking against that (you'll need a msvcp71.lib file: see
http://forums.codeblocks.org/index.php/topic,821.msg5668.html#msg5668
steps 4&5 for directions on building it).  It's worth noting that if libraries you link against use the runtime dll this doesn't mix (I don't think) with trying to use the static runtime dll (libc.lib) so that you may have to link against the dll runtime...

« Last Edit: September 07, 2005, 02:23:51 am by grv575 »

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: DirectX 8 & 9
« Reply #7 on: September 07, 2005, 08:42:26 am »
Now that grv575 mentions it, I recall a similar problem being solved by adding libcp.lib in link libs...
Be patient!
This bug will be fixed soon...

MrTAToad

  • Guest
Re: DirectX 8 & 9
« Reply #8 on: September 08, 2005, 11:52:24 pm »
It wasn't solved by linking in libcp.lib unfortunately.

I've tried linking in single and multi-thread library (both release and debug).

Unfortunately whilst linking with the VS7 library files would be ideal, unfortunately the idea of trying to use code::blocks with DarkSDK is to allow those who are too poor to stump up £70 for it to use the SDK.  And to be honest anything that cant be used out of the box would be too complicated for a lot of people.

Quote
There's tips about compiling darksdk on this page:
http://homepages.nildram.co.uk/~nickk/html/q___a.html
I wrote that and its for Visual Studio 2003.  Considering that I closed my Nildram account down 2 months ago, I can still access everything there.

grv575

  • Guest
Re: DirectX 8 & 9
« Reply #9 on: September 09, 2005, 05:44:27 am »
masm32 (an assembler distribution that uses ms ml.exe, link.exe) gets around this by generating the .lib file on installation.  they have .inc include headers which detail the symbols found in the windows system dlls and then a custom program generated .lib file using this information.

what you could do is include a mingw compiled sed program.  then just create a batch file that accepts an dllname as an argument and generates the .lib file according to that exports_alt.sed script.  just tell users to click on the script to generate the lib file for them and have it put the .lib file somewhere in the path for them.

So if you want to pursue this, grab sed.exe at:
http://prdownloads.sourceforge.net/gnuwin32/sed-4.1.4.exe

Here's the exports_alt.sed script:
-----cut here---------
# echo LIBRARY msvcp71.dll > msvcprt.def
# echo EXPORTS >> msvcprt.def
# link -dump -exports msvcp71.dll | sed -nf exports_alt.sed >> msvcprt.def
# link -lib -machine:X86 -def:msvcprt.def -out:msvcprt.lib
#
/[ \t]*ordinal hint/,/^[ \t]*Summary/{
 /^[ \t]\+[0-9]\+/{
   s/^[ \t]\+[0-9]\+[ \t]\+[0-9A-Fa-f]\+[ \t]\+[0-9A-Fa-f]\+[ \t]\+\(.*\)/\1/p
 }
}
-----cut here---------

Note the line endings in exports_alt.sed must be unix line endings (just LF, not CR/LF).
So either run dos2unix.exe on the file after cuting and pasting the above to a file, or use a text
editor which supports unix line endings (e.g. ultraedit).

Here's the dll2lib.bat batch script:
-----cut here---------
@echo off

REM call with dll2lib dll_basename lib_basename
REM e.g. dll2lib msvcp71 msvcprt
REM will look for msvcp71.dll in the current directory
REM and produce msvcprt.lib in the current directory
REM alt_exports.sed needs to be in the current directory
REM sed.exe (and libiconv2.dll, libintl3.dll) from gnuwin32 need to be in the PATH

set PATH="C:\Program Files\Microsoft Platform SDK\Bin\win64";%PATH%
echo LIBRARY %1.dll > %2.def
echo EXPORTS >> %2.def
link -dump -exports %1.dll | sed -nf exports_alt.sed >> %2.def
link -lib -machine:X86 -def:%2.def -out:%2.lib
-----cut here---------

This assumes you bundle sed.exe, the two lib files it needs (libiconv2.dll, libintl3.dll) which are in the same directory as sed.exe installs to, and that Platform SDK is installed on the user's machine.  Then they just run
dll2lib msvcp71 msvcprt
to produce the msvcprt.lib file that's needed to link "Multi-threaded DLL Runtime Library".

---

Btw, I figure out the error message you were getting with _Xlen.  This is a custom MS extension to the C++ library.  The include files are in C:\Program Files\Microsoft Platform SDK\Include\crt
Specifically, see the file "xstring" in that dir.  The dll which defines these functions is the microsoft runtime library (msvcrpt*.dll or msvcrt*.dll).  So it is necessary to use the MS runtime for this.  The standard C library doesn't look like it provides the crt extensions.
« Last Edit: September 09, 2005, 06:50:04 am by grv575 »

MrTAToad

  • Guest
Re: DirectX 8 & 9
« Reply #10 on: September 09, 2005, 09:14:34 am »
Unfortunately still getting the _Xlen problem, even with a sed version of msvcrt and msvcprt - it got a bit further but still complained.