Author Topic: Cannot find -ldxerr when linking  (Read 10453 times)

Offline TwoD

  • Single posting newcomer
  • *
  • Posts: 8
Cannot find -ldxerr when linking
« on: May 17, 2008, 05:34:13 pm »
I followed this guide: http://wiki.codeblocks.org/index.php?title=Code::Blocks_and_Cross_Compilers to set up CB with MinGW to compile some of my Windows projects from Linux. I'm in Ubuntu 8.04 and running the 8.02 release of CB (just upgraded from an old svn nightly installed via someone's .deb package). MinGw is version 4.2.1.dfsg-1ubuntu1.

I had to change the path on the Toolchain tab to just /usr to get it to not complain about invalid compiler [YOUR ANSWER IS ALREADY THERE. SEARCH THE FORUMS!].

I managed to get a small console game I made in Visual Studio compile, link and run without much fuss. I even managed to compile, link and run the Ogre examples, despite a few problems regarding strings and DLL-boundries.
But when I tried with another of my projects using D3D9 and D3DX9 (the d3d & d3dx libraries and headers were included with the project to make sure we all used the same versions when the project was in development) I get this error when linking starts:
Quote
Linking console executable: test/SeondEncounter_Debug.exe
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/bin/ld: cannot find -ldxerr
collect2: ld returned 1 exit status

I have searched for -ldxerr everywhere but I can't find anything related to it. I noticed the path to ld looks a bit weird, I thought it would use /usr/i586-mingw32msvc/bin/ld but I'm not sure how all this works as I'm not used to Linux development.

If this question is better asked somewhere else, please redirect me there as I have no clue where to start. Thanks!
« Last Edit: May 17, 2008, 07:15:13 pm by TwoD »

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Cannot find -ldxerr when linking
« Reply #1 on: May 17, 2008, 07:06:04 pm »
You can also have a look int this wiki-article.

I wrote it to setup C::B for cross-compiling wxWidgets-apps from linux, but the setup works also for console apps and the standard C::B wizard project.

You only have to chose the cross-compiler and fix the properties for the build target as written here.


Offline TwoD

  • Single posting newcomer
  • *
  • Posts: 8
Re: Cannot find -ldxerr when linking
« Reply #2 on: May 17, 2008, 07:24:43 pm »
Thanks for the quick reply.

I read through the text but found nothing different from my current setup (except of course the WxWidget specific settings).

What puzzles me is that both compiler and linker runs fine on some projects, but not on others.

Do you know what -ldxerr is? I'm guessing something related to the linker and errors but then I'm lost.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: Cannot find -ldxerr when linking
« Reply #3 on: May 17, 2008, 09:53:33 pm »
Do you know what -ldxerr is? I'm guessing something related to the linker and errors but then I'm lost.

Google results says DirectX error reporting library.

This link might help porting stuff, I am guessing an problem in MinGW based GCC 4.2.1 you are using.

http://www.devdaily.com/scw/c/cygwin/src/winsup/w32api/lib/directx/dxerr.c.shtml

Tim S
« Last Edit: May 17, 2008, 09:58:36 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 TwoD

  • Single posting newcomer
  • *
  • Posts: 8
Re: Cannot find -ldxerr when linking
« Reply #4 on: May 17, 2008, 10:17:35 pm »
Just to be sure I didn't mess up some project setting (I've been tinkering with this project for a while), I made a completely new project in CB and added all the files from the old project. I also added the include/lib paths to fmod and D3D & D3DX libs (the project used to be compiled against the August 2006 release and that's what I'm trying to make it do again, before switching to the latest version.).

This time around it worked a bit better. Compile worked fine and linking actually does something, but it can't find some stuff from DxErr.h (also tried dxerr9.h and the corresponding .lib):
Quote
Linking console executable: bin/Test.exe
collect2: ld terminated with signal 11 [Segmenteringsfel] (segfault in Swedish)
Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" ' unrecognized
Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" ' unrecognized
Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" ' unrecognized
Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" ' unrecognized
/home/henrik/Projects/SOFE/SecondEncounter/lib/dxSdkAugust2006/DxErr.lib(obj/i386/dxerr.obj): In function `_DXTraceW@20':
d:\bt\256\private\:32766: undefined reference to `__chkstk'
d:\bt\256\private\:(.text[_DXTraceW@20]+0x10): undefined reference to `___security_cookie'
d:\bt\256\private\:46: undefined reference to `@__security_check_cookie@4'
/home/henrik/Projects/SOFE/SecondEncounter/lib/dxSdkAugust2006/DxErr.lib(obj/i386/dxerr.obj): In function `_DXTraceA@20':
d:\bt\256\private\:32766: undefined reference to `__chkstk'
d:\bt\256\private\:(.text[_DXTraceA@20]+0x10): undefined reference to `___security_cookie'
d:\bt\256\private\:46: undefined reference to `@__security_check_cookie@4'

I've looked around for solutions to this and found some sources, like the Ogre forum, mentioning adding the /GS flag as a fix. But that only works in MSVC...
http://www.ogre3d.org/phpBB2/viewtopic.php?p=251086&sid=ce193664e1d3d7c4af509e6f4e2718c6
Also tried removing the reference to the dxerr libfile, which worked for someone there, but that just lead to an undefined reference to DXGetErrorDescription as expected (called from the resource manager, I can live without it but it'd be great to know why it fails.)

I know that reference errors are a bit off topic and in no way related to CB so I don't expect much help with that here, but it would of course be greatly appreciated.

EDIT: Just an update on my progress: I got rid of the undefined references by not using DXGetErrorDescription, and thereby not using the DxErr header/lib. But I still get the segfault on ld, so I ran it with -v to maybe give someone a clue to what's going on.
Quote
Linking console executable: bin/Test.exe
Using built-in specs.
Target: i586-mingw32msvc
Configured with: /build/buildd/mingw32-4.2.1.dfsg/build_dir/src/gcc-4.2.1-2-dfsg/configure -v --prefix=/usr --target=i586-mingw32msvc --enable-languages=c,c++ --enable-threads --enable-sjlj-exceptions --disable-multilib --enable-version-specific-runtime-libs
Thread model: win32
gcc version 4.2.1-sjlj (mingw32-2)
 /usr/libexec/gcc/i586-mingw32msvc/4.2.1-sjlj/collect2 -Bdynamic -o bin/Test.exe /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/lib/crt2.o /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/crtbegin.o -L/home/henrik/Projects/SOFE/SecondEncounter/lib/dxSdkAugust2006 -L/home/henrik/Projects/SOFE/SecondEncounter/lib/fmod -L/usr/i586-mingw32msvc/lib -L/media/Storage/API/OgreSDK/lib -L/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj -L/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj -L/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/lib obj/Test/src/BoundingBox.o obj/Test/src/Camera.o obj/Test/src/Engine.o obj/Test/src/Font.o obj/Test/src/InputManager.o obj/Test/src/Listener.o obj/Test/src/Math.o obj/Test/src/MatrixUtils.o obj/Test/src/Mesh.o obj/Test/src/MovableObject.o obj/Test/src/Node.o obj/Test/src/ParticleSystem.o obj/Test/src/Planet.o obj/Test/src/PowerUp.o obj/Test/src/Projectile.o obj/Test/src/Quad.o obj/Test/src/RenderQueue.o obj/Test/src/Renderer.o obj/Test/src/ResourceManager.o obj/Test/src/SOUND.o obj/Test/src/SceneManager.o obj/Test/src/SceneNode.o obj/Test/src/Shader.o obj/Test/src/SpriteObject.o obj/Test/src/StandardWindow.o obj/Test/src/Texture.o obj/Test/src/enemy.o obj/Test/src/entity.o obj/Test/src/main.o obj/Test/src/player.o obj/Test/src/timer.o obj/Test/src/weapon.o -lstdc++ -lgcc -lodbc32 -lwsock32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lctl3d32 -lodbc32 -ladvapi32 -lodbc32 -lwsock32 -lopengl32 -lglu32 -lole32 -loleaut32 -luuid /home/henrik/Projects/SOFE/SecondEncounter/lib/dxSdkAugust2006/dinput8.lib /home/henrik/Projects/SOFE/SecondEncounter/lib/dxSdkAugust2006/d3dx9d.lib /home/henrik/Projects/SOFE/SecondEncounter/lib/dxSdkAugust2006/d3d9.lib /home/henrik/Projects/SOFE/SecondEncounter/lib/fmod/fmodvc.lib /home/henrik/Projects/SOFE/SecondEncounter/lib/dxSdkAugust2006/dxguid.lib -lstdc++ -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt -luser32 -lkernel32 -ladvapi32 -lshell32 -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/crtend.o
collect2: ld terminated with signal 11 [Segmenteringsfel]
Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" ' unrecognized
Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" ' unrecognized
Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" ' unrecognized
Process terminated with status 1 (0 minutes, 4 seconds)
0 errors, 8 warnings
The warnings are mostly "warning: ignoring #pragma warning ", there are usually a lot more but this was a partial recompile/link after me removing the DxGetError... call.
« Last Edit: May 18, 2008, 01:44:05 am by TwoD »

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Cannot find -ldxerr when linking
« Reply #5 on: May 18, 2008, 07:55:56 am »
1. You can't link MSVC compiled libraries against GCC compiled object files.
2. Don't use MSVC compiler options for GCC. E.g., /DEFAULTLIB:"uuid.lib" is applicable for MSVC only.
Be a part of the solution, not a part of the problem.

Offline TwoD

  • Single posting newcomer
  • *
  • Posts: 8
Re: Cannot find -ldxerr when linking
« Reply #6 on: May 18, 2008, 06:34:51 pm »
Sigh... All this is driving me nuts. Thank you all for still replying despite my somewhat extremely complete and utter confusion on this matter.  :?
Brace yourselves tho, it's getting worse. I've decided I need to start over from scratch to understand how to make my D3D(X) programs compile, link and run (with Wine) in Linux, as well as run in Windows without code changes.

In reply to Biplab:
1. From what I've read, the "self hosted MinGW version" will have the ability to link with a .dll/.lib pair created with MSVC, but I don't know which actual version that is (I'm using the one from Ubuntu repositories), nor am I certain that's true since every piece of documentation I've come across so far has been extremely confusing. Most of the FAQs or HowTo's I've come across are either exact copies or rewordings of the MinGW official FAQ, which in turn is IMHO gibberish.

The few texts I've found which I could make sense of says that to link with a Windows-dll, I need either a .lib-file (must be the one included with the 3rd party library, such as d3dx9.lib, righ? But you say that won't cut it because of incompatibilities) or an .a file, which I obviosly don't have since d3d's obviously been compiled for Windows with MSVC.

To create a .a file I need a .def file with all the symbols available in the .dll. Of course I don't have a .def file either.

To create a .def file I could use the .dll and the dllwrap tool. (Other tools like dlltool, libtool, nm are also mentioned for the various tasks needed to get the elusive .a file I need for linking, but the following "issues" apply to them as well) The .dll in my case would be d3dx9_xx.dll, right? I grabbed one (d3dx9_35.dll) from my Vista installation to test.
I have i586-mingw32msvc-dllwrap which came with MinGW, is this the tool they mean? I don't know what the actual difference is compared to just "dllwrap" (which I don't have). Some of the other tools I do have two versions of, the "regular" ones without "i586-mingw32msvc" and those with. What is what and why?
Anyway, I tried using i586-mingw32msv-dllwrap with the specified switches, but all it produced was an empty .def file and then said there were no symbols found. :(
I'm once again lost...

I tried an alternative route; find .a files someone else had already made for d3dx.
I came across this page: http://mywebpage.netscape.com/PtrPck/directx.htm, where someone has made import libraries for d3dx8. Wrong version I know but I gave it a shot just to see what happened.
I added the new d3dx path to the Project's Search Directories -> Linker in CB to point to the files I downloaded from the above site and compiled.
Compile worked fine, and linking too (no segfault), except for a few undefined references to methods like _D3DXCreateEffectFromFileA@32 which I presume is because I used d3dx9 headers but only had the d3dx8 import library.

I tried to follow the guide on the link above to create import libraries for d3dx9 as well, but lost him when he mentions a tool called "reimp" which I don't have.

2. I don't know where that compiler option is set. I have not set it explicitly so I'm thinking it's somehow added by the D3D(X) headers.


The only reason I keep trying to do this is that I tell myself I'm learning something new, which I will benefit from greatly later on. But I will owe much of the effort to all of you who keep replying, so thank you all once again!

Offline dosboot

  • Single posting newcomer
  • *
  • Posts: 3
Re: Cannot find -ldxerr when linking
« Reply #7 on: June 03, 2008, 06:34:57 am »
Yep, this sounds exactly right.  I was in your situation a year or two ago.  Same DirectX version (August 2006 SDK).  Searched and found the same site with the dxerr header that didn't work.  Tried to create .def files using tools I have no clue about but got the same empty file....

Unfortunately I gave up.  This is something that has to be taught.  In the end it probably won't be complicated, it is just very hard to learn in isolation.  How everyone else in the world learned all one needs to know about .dll/.lib/.a/.def files is beyond me.

Ah well.  As you found out, since only the error library is affected you can sort of get by without solving the problem.  My project seems to be working nicely, with no misbehavior from the other DirectX calls I've thrown at it.  I can try to help if you ever need to compare notes with another person compiling DirectX on mingw.

Offline TwoD

  • Single posting newcomer
  • *
  • Posts: 8
Re: Cannot find -ldxerr when linking
« Reply #8 on: June 03, 2008, 04:29:13 pm »
I finally managed to get it all working, and get a grip on some of the things I was so confused about.
After some additional searching and rewordings of my queries I discovered this site: http://devpaks.org/ which has "adapted" libraries for Dev-C++.
Someone has already gone through the hassle of porting the DX 9.0c .libs (including D3DX) to .a files and uploaded it here: http://devpaks.org/details.php?devpak=136
I'm unsure which actual SDK version it is, and I can't check atm since my comp isn't up (moving to our new place took waaaay longer than expected), but I know it atleast works with what I needed from the Aug 2006 version. As noted on devpak's front page, the .devpak file is just a renamed .tar.bz2, and they are not responsible for what it contains!

I even managed to create a Linux version of another library I used and I've been thinking of writing a small tutorial on how to do it. It would probably be very similar to the tutorials mentioned here, but with some more focus on DX and elaborations on why you do each step, and with links to any programs/libs etc.

I'd be glad to compare notes some time. =)

Offline dosboot

  • Single posting newcomer
  • *
  • Posts: 3
Re: Cannot find -ldxerr when linking
« Reply #9 on: June 05, 2008, 07:13:17 am »
The download link doesn't seem to be working anymore.  Any idea where else I could get this?

Offline TwoD

  • Single posting newcomer
  • *
  • Posts: 8
Re: Cannot find -ldxerr when linking
« Reply #10 on: June 06, 2008, 10:41:21 pm »
Which link? If you meant the devpak I can upload it somewhere as soon as I get my own computer online again.

Offline dosboot

  • Single posting newcomer
  • *
  • Posts: 3
Re: Cannot find -ldxerr when linking
« Reply #11 on: June 07, 2008, 04:01:35 am »
It's ok, the devpak download is working now.  I'll have to dust off my memory of all this def/lib business and play with it over the weekend.  I can't find any info about the devpak that explains what the creators did and why it was necessary.  If you figured it out I would be interested in learning.  You also said that much of this stuff is similar to what is laid out in tutorials here, can you point me to the tutorials you are talking about?

Offline TwoD

  • Single posting newcomer
  • *
  • Posts: 8
Re: Cannot find -ldxerr when linking
« Reply #12 on: June 07, 2008, 01:09:12 pm »
I was thinking about this FAQ/tutorial: http://www.mingw.org/mingwfaq.shtml#faq-msvcdll
Start reading from "The other way is to produce the .a files for GCC."

I didn't get the reimp tool to work with my .libs (as some won't). But creating a plain text .def from the original DLL import .lib with pexports (I think I had to download it separately), manually edit the file due to different naming conventions in GCC and MSVC and then use i586-mingw32mscv-dlltool (or was it just "dlltool", or maybe both worked, sorry I don't remember and my own computer is still not up) on the .def produced a usable .a file for my DLL.

Then I set the linker search folders in Code::blocks to include the dir where the .a file was, and also set it to link to my .a file (without the file extension), as usual. Be careful if you have both a .lib and .a with the same name as I think it could confuse the linker as I think it can actually link with .libs in some cases (it's mentioned in the FAQ somewhere but it seems a bit fuzzy).