User forums > Using Code::Blocks
Problem creating same output as VS 2005
yamokosk:
I am sure you devs already hear this enough but.. wow, CB is amazing. I finally gave up on VS 2005 after being annoyed to no end by countless hang ups and a very, very sluggish intellijoke system. Great work guys! Keep it up.
However, I have run into a little bit of a snag. I have been using VS 2005 to compile Matlab MEX files (really just a DLL with a special exported function - mexFunction). But I can't seem to get CB to properly build these same MEX projects. To help debug this problem, I created a simple "Hello World" MEX project in Visual Studio. When I compile the library and then dumpbin the contents I get:
--- Quote ---Microsoft (R) COFF/PE Dumper Version 8.00.50727.762
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file SimpleMexVS.mexw32
File Type: DLL
Section contains the following exports for SimpleMex.dll
00000000 characteristics
467A8F0C time date stamp Thu Jun 21 10:45:32 2007
0.00 version
1 ordinal base
1 number of functions
1 number of names
ordinal hint RVA name
1 0 0001101E mexFunction = @ILT+25(_mexFunction)
Summary
1000 .data
1000 .idata
2000 .rdata
1000 .reloc
1000 .rsrc
4000 .text
10000 .textbss
--- End quote ---
Then in CB (nightly build, Jun 18, 2007) I have created an identical project (DLL target, using VS 2005 compiler, same source code, and meticulously copied every option from VS to CB). But when I compile in CB then dumpbin the contents of the library I get something different:
--- Quote ---Microsoft (R) COFF/PE Dumper Version 8.00.50727.762
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file SimpleMexCB.mexw32
File Type: DLL
Section contains the following exports for SimpleMex.dll
00000000 characteristics
467AA204 time date stamp Thu Jun 21 12:06:28 2007
0.00 version
1 ordinal base
1 number of functions
1 number of names
ordinal hint RVA name
1 0 00001005 mexFunction = @ILT+0(_mexFunction)
Summary
1000 .data
1000 .idata
2000 .rdata
1000 .reloc
1000 .rsrc
4000 .text
--- End quote ---
This difference is important because when I try to load each respective function in MATLAB I get an error from the CB compiled version. Anyone have any ideas where to proceed. As I said, I have double checked that all compile/linker options, preprocessor symbols, etc are the same between the VS and CB projects. Are there any other debugging ideas anyone can think of?
mandrav:
Morten us building matlab dlls with C::B but he's not using the VC compiler. He's using LCC or GCC.
Maybe he has something to share...
MortenMacFly:
--- Quote from: mandrav on June 21, 2007, 09:48:55 pm ---Maybe he has something to share...
--- End quote ---
I have. ;-)
Well - I can't really help you with VC2005 as I don't have it. But for this case I think you are still missing some compiler flags. Have a look at the mex batch file that is used (setup) for your compiler... (I assume you know the interna of the mex build process). This was my starting point, too when it came to what compiler/linker flags to use. In addition it could be that you are linking against the wron MSVC lib - remember that Matlab ships with several one, depending on the VC compiler you are using. Hopefully you didn-'t forget to link against the required Matlab libs, too... but this should throw a linker error otherwise.
I am using the Matlab built-in LCC (I have a special version of C::B for that - including support for that compiler) or the MinGW/GCC. The latter is not easy to configure, but it is possible. I can guide you through it if you like. If you need the VC compiler (I can imagine several reason why this could be the case) try to compile with another version in addition - VC6, if this is available to you. Search the C::B WiKi for information how to setup this compiler in C::B. I only have that compiler so I could help you better then... maybe... ;-)
With regards, Morten.
yamokosk:
Morten-
Good point about checking the Matlab options file for my compiler. There was one or two options listed in it that neither VS nor C::B contained. But adding them to C::B did not remedy the situation.
Here is what I don't understand. C::B is merely an IDE. Under the covers, it is doing everything VS is doing.. calling cl.exe + my options, calling link.exe + my options, etc. And if I can verify that "my options" are the same between both programs (which I am guessing they are not), then they should both produce identical output.
Is there any way to capture the command terminal steps of both programs? So I can see what is actually being passed to cl.exe by VS and cl.exe by C::B?
(btw, if anyone was wondering I did track down one of the differences in the dumpbin's between the two compiled libraries. From MS documentation, "Section .textbss is only required by Microsoft Visual C++ 7.0 and higher if incremental linking is used." I verified that /INCREMENTAL is a linker option in both C::B and VS... But the C::B dumpbin does not contain a .textbss section. Is the /INCREMENTAL option not getting passed to link.exe in C::B?)
mandrav:
--- Quote ---Is there any way to capture the command terminal steps of both programs? So I can see what is actually being passed to cl.exe by VS and cl.exe by C::B?
--- End quote ---
I can't help you with VS (as I don't have it), but for C::B do this:
Go to "Settings->Compiler and debugger", select your compiler from the drop-down list at the top and then click on the "Other" page. There, select the logging option and set it to "Full logging". This will print the full build commands, as executed.
Navigation
[0] Message Index
[#] Next page
Go to full version