Building with Borland Turbo C++

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Quibbler
Posts: 25
Joined: Tue Feb 14, 2006 5:34 pm

Building with Borland Turbo C++

Post by Quibbler »

Finally, I succeeded building Irrlicht.dll (latest 1.3 version) with Borland Turbo 2006.

I logged everything I did and will soon compile a step-by-step guide (see post below) for anyone interested.

All examples except number 15 (LoadIrrFile) worked at first build after adding these lines in main() and #included <float.h> (credits to etcaptor for this):

#if defined(__BORLANDC__) || defined(__BCPLUSPLUS__)
_control87(MCW_EM,MCW_EM);//float.h
#endif
However, in each example I got question marks in the caption bar of the main window and in example 06.Meshviewer I got strange characters.
This is not a big mystery after all.

The thing is, I made an ugly work-around in irrString.h just to be able to compile it with Borland's compiler without doing too much modifications.
Before the modifications, I received this strange error inside the template <class B> operator= function:

Size of type B is unknown or zero

Anyone had this compiler error?

It seems there is some sort of compiler bug here, but I'm not sure.
The quoted problem has been solved.
The problem was never in irrString.h, but in CCSMLoader.cpp in the function void Surface::clear() and on this row:

textureName = 0;

I changed it to this:

textureName = "";

Voila! The problem is solved. All examples works as expected.

The 'compiler bug' seems to be that the compiler doesn't know how to treat a zero as parameter in the template function.
According to Stroustrup (section 5.1.1) a zero (0) is an int.
Now, the assignment operator function has const B* as parameter type, so I guess it tries to generate a function with a zero as the pointer adress, and I believe that is why I got the "Size of the type B is unknown or zero" error, because it don't know what type is on address 0.
Last edited by Quibbler on Thu Apr 12, 2007 4:03 pm, edited 7 times in total.
Quibbler
Posts: 25
Joined: Tue Feb 14, 2006 5:34 pm

Step-by-step guide

Post by Quibbler »

Here comes the step-by-step guide about how to build the irrlicht engine as a .dll with Borland Turbo C++ 2006.

Please copy and paste in your favourite text editor.

Enjoy!


BUILDING IRRLICHT ENGINE AS A DLL WITH TURBO C++ 2006
-----------------------------------------------------

NOTE: THESE INSTRUCTIONS APPLIES ONLY TO SDK VERSION 1.3.1 OR ABOVE

Follow the instructions below to be able to build
the Irrlicht engine with Borland Turbo C++ as a DLL.

If you want to compile with JPEG support (probably you want that ;-)
you need to first delete jconfig.h in the jpeg folder and rename
the file named jconfig.bcc to jconfig.h


Make a new project and choose DLL-project in the wizard.
Make sure that Multithreaded and VC++ Style DLL check boxes are checked.


Go to Project Options and define one of these (Conditional Defines)
_XBOX for XBox
WIN32 for Windows32
WIN64 for Windows64
_IRR_WINDOWS_ for all irrlicht supported windows versions
OS2 for OS/2
MACOSX for Mac OS X
LINUX for linux and unix

Also don't forget to define IRRLICHT_EXPORTS
(Seperate defines with ;)

You may choose whatever calling convention that suits your particular needs.

Under linker options, make sure Generate import library is checked.


Open the file IrrCompileConfig.h (located in /include)
and read the comments. Simply comment out things you don't want.

Rename Irrlicht.cpp to startup.cpp in the source/irrlicht folder
This is needed because of some unknown reason the IDE says there is
already a form or module named Irrlicht when we try to rename the project.

Rename Project1.dll to Irrlicht.dll in the Project Manager.

Add all source files in the source folder to the project
(Use menu option Add to project... or Shift+F11)

You also need to add all source files from the zlib, jpeglib and libpng
folders EXCEPT these files:

From the jpeglib folder:

example.c
jmemname.c
jmemansi.c
jmemdos.c
jmemansi.c
jmemmac.c

From the libpng folder:

example.c
pngtest.c

Now you have hopefully added all necessary source files to your project.
Now you need to modify some of them.

-----------------------------------------------------------------------------

Edit following file:

startup.cpp

Locate this:

#if defined(_DEBUG) && !defined(__GNUWIN32__)
_CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF | _CRTDBG_ALLOC_MEM_DF);
#endif

Change to this:

#if defined(_DEBUG) && !defined(__GNUWIN32__) && !defined(__BORLANDC__)
_CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF | _CRTDBG_ALLOC_MEM_DF);
#endif

-----------------------------------------------------------------------------

Edit following files in the libpng folder:

pngerror.c
pngtrans.c

Search for lines containing the macro PNG_CONST
Delete the keyword const in front of those lines.
If you don't delete the const keyword, compiler complains about const specified more than once.


That's it!
Now you should be able to build your own Irrlicht.dll file
(should be approx. 1.8 MB large for non-DX version)

Remember to include the import library (Irrlicht.lib) when compiling the examples.

You may also have to include these lines when running examples:

#if defined(__BORLANDC__) || defined(__BCPLUSPLUS__)
_control87(MCW_EM,MCW_EM);//float.h
#endif

Just add them in the beginning of main() or somewhere else.
Don't forget to #include <float.h>

Good luck!
Last edited by Quibbler on Mon Sep 24, 2007 8:54 pm, edited 2 times in total.
HLFat
Posts: 71
Joined: Sun Sep 24, 2006 6:55 pm
Location: USA

Post by HLFat »

I did a static version of the library, by starting a new static lib project.

Seems to work Ok, but the library is extremely large , about 35.4 MB.

Don't know why it is so large, my Digital Mars version of the static lib is only 5.45 MB.

However, it just links in the parts you need, so the EXEs are are probably typical in size.For example the Quake3MapShader.exe is about 1.75 MB.
Borath
Posts: 10
Joined: Fri Nov 17, 2006 4:57 am

Post by Borath »

hmm,
i think i am too lame to compile the dll using borland.
Errors like min-function not found (used in DX-SDK-Source) or
[C++ error] CIrrDeviceWin32.cpp(453): E2316 'CIrrDeviceWin32::createDriver(video::E_DRIVER_TYPE,const core::dimension2di &,unsigned int,bool,bool,bool,bool,bool)' is not an element of 'CIrrDeviceWin32'
I started to check the sourcecodes for the fixes listed above, but most of them are already fixed in 1.3.1, so i really dont know what to do now.

Can any nice person provide me a ready-to-go dll and lib for borland c++ builder 2006?


regards,
B
HLFat
Posts: 71
Joined: Sun Sep 24, 2006 6:55 pm
Location: USA

Post by HLFat »

I believe the only thing I had to do was add the min macro to CD3D9Driver.cpp:

Code: Select all

#define min(a, b)  (((a) < (b)) ? (a) : (b))
.

That's with Irrlicht 1.3.1 and the Borland Turbo tools (Turbo C++ 2006).

Oh...some of the PNG library files had to be modified.A 'const' had to be removed.Pngerror.c and Pngtrans.c.
Borath
Posts: 10
Joined: Fri Nov 17, 2006 4:57 am

Post by Borath »

Yes, thats the that macro helped on the min-function, but i still get the folloring error:
[C++ Fehler] CIrrDeviceWin32.cpp(453): E2316 'CIrrDeviceWin32::createDriver(video::E_DRIVER_TYPE,const core::dimension2di &,unsigned int,bool,bool,bool,bool,bool)' ist kein Element von 'CIrrDeviceWin32'
translated to english:
[C++ error] CIrrDeviceWin32.cpp(453): E2316 'CIrrDeviceWin32::createDriver(video::E_DRIVER_TYPE,const core::dimension2di &,unsigned int,bool,bool,bool,bool,bool)' is not an element of 'CIrrDeviceWin32'
Can someone help me on that one?

regards,
B
HLFat
Posts: 71
Joined: Sun Sep 24, 2006 6:55 pm
Location: USA

Post by HLFat »

I don't know ... CIrrDeviceWin32.cpp builds fine with the Turbo tools and the BCC 5.5.1 command line tools.

However try
[C++ error] CIrrDeviceWin32.cpp(453): E2316 'CIrrDeviceWin32::createDriver(video::E_DRIVER_TYPE,const core::dimension2di &,unsigned int,bool,bool,bool,bool,bool)' is not an element of 'CIrrDeviceWin32'
to remove the const from const core::dimension2d.

See what that does.
Borath
Posts: 10
Joined: Fri Nov 17, 2006 4:57 am

Post by Borath »

Ok, thanks for the hint.
I had to remove also several CONST Keywords in the png - libraries, just like you.

The Compiler finishs now with thousands of warning, but the linker fails now.
The errormessage says nothing but "fatal access violation. Linking stopped."
BTW i am building using the IDE. AFAIK that should not matter, right?
HLFat
Posts: 71
Joined: Sun Sep 24, 2006 6:55 pm
Location: USA

Post by HLFat »

The Compiler finishs now with thousands of warning, but the linker fails now.
The errormessage says nothing but "fatal access violation. Linking stopped."
BTW i am building using the IDE. AFAIK that should not matter, right?
I normally turn off all the warnings,option -w-.

Linking fatal access violation. I have seen that when I use the Borland Turbo Tools with the Code::Blocks IDE.But it starts to work.Let me look into that.

It should work with the Builder IDE.

Where are your .obj files going?Try changing the project so they go in the source directory.

Edit: are you building the DLL or the static lib.Be sure IRRLICHT_EXPORTS is defined for the DLL.To build the static lib define _IRR_STATIC_LIB_.

Try building the static lib.You will have to start a new project.The linker is not used in the static lib.Just TLIB is used.
Borath
Posts: 10
Joined: Fri Nov 17, 2006 4:57 am

Post by Borath »

Hello,

and thx for your time and tries to help.
I am going to build the dll and defined IRRLICHT_EXPORTS
I adjusted the output directory of the .obj files to the sourcefolder, but it did not help. I still get this "Linking fatal access violation" error of the linker when i try to link the dll.

Next step i will try is either try to build the lib or just switch to the well-known c++ compiler of Microsoft :cry:

so far,
B
etcaptor
Posts: 871
Joined: Fri Apr 09, 2004 10:32 pm
Location: Valhalla
Contact:

Post by etcaptor »

Try to remove all paths in Intermediate Output and Final Output in your project options. Linking fatal access violation error appears usually when linker can't find similar paths on your drive.
Also if you use directory like C++Builder in your project, you must rename it like CBuilder because linker not likes paths that contains ++ or --

If you still have problems I can upload sources and compiled dll on ftp, but seems Irrlicht team made a good work because in this version you need only several changes for Borland compatibility
ImageImage
Site development -Rock and metal online
--- etcaptor.com ------freenetlife.com
Borath
Posts: 10
Joined: Fri Nov 17, 2006 4:57 am

Post by Borath »

That could be the reason. My Path is

C:\Dokumente und Einstellungen\ich\Eigene Dateien\c++ - projekte\irrlicht
I will try this tonight!

Edit:
Sorry to bug you guys again and again. now the Linker gives a more specific error: Fatal Error: File 'JMEMDOSA.OBJ' could not be opened.

There is a jmemdosa.asm file, but no obj.
As described i did not add the four .c files of jpeglib directory, but if i add them i get compiler errors.
Any Idea on that one?
HLFat
Posts: 71
Joined: Sun Sep 24, 2006 6:55 pm
Location: USA

Post by HLFat »

There is a jmemdosa.asm file, but no obj.
As described i did not add the four .c files of jpeglib directory, but if i add them i get compiler errors.
Any Idea on that one?
You need to edit the files you are using for LIBPNG,ZLIB,and JPEGLIB.Not all the files are used for Irrlicht.

'JMEMDOSA.ASM' is not used,as well as a bunch of other files.

One way to find the correct files is to open the the Code::Blocks project IrrlichtWin32_GCC.cpb with a text editor (I use Wordpad) and look for the files there.

Or.... I'll just PM you the file names from my Code::Blocks project readout.The Build log.

OK...three PMs with build log and link info.

Oh...I missed EtCaptor's post. He's the genius with Borland Builder.
Next step i will try is either try to build the lib or just switch to the well-known c++ compiler of Microsoft
Don't give up yet!! You are almost there.
etcaptor
Posts: 871
Joined: Fri Apr 09, 2004 10:32 pm
Location: Valhalla
Contact:

Post by etcaptor »

I have not any problems with JMEMDOSA.asm. Maybe must upload files for you. Currently I use BCB6, but tomorrow will compile files with 2006 version and hope that you will have not problems. I tried my old VisualEditor project with Irr 1.3.1 after 1.5 yeahr and it works. Seems Irrlicht dev team made most of task related with BCB compatibility and there stays only several changes.
ImageImage
Site development -Rock and metal online
--- etcaptor.com ------freenetlife.com
Borath
Posts: 10
Joined: Fri Nov 17, 2006 4:57 am

Post by Borath »

HLFat wrote: Oh...I missed EtCaptor's post. He's the genius with Borland Builder.
Don't give up yet!! You are almost there.
Yes, i also noticed that EtCaptor seems to be a pro on bc.
I think i will wait until he tried Borland Developer Studio 2006.

Any Flat, you are right - i made it so far, i wont give up and go to MS!
Post Reply