Welcome to Fractal Forums

Fractal Software => Mandelbulber => Topic started by: ker2x on May 14, 2010, 11:08:52 PM




Title: Compiling on VS2010 C++ Express
Post by: ker2x on May 14, 2010, 11:08:52 PM
I successfully compiled mandelbulber on win7 using Code::Block

Now i'm trying with VS2010 C++ Express
Here come troubles, of course   :embarrass:

I'm a newbie with VStudio stuff  :hmh:

The first problem was 'M_PI' : undeclared identifier"
Easily solved by adding #define _USE_MATH_DEFINES before every include of math.h

A thread on microsoft connect suggest : to define _USE_MATH_DEFINES in ProjectProperties/C++/Preprocessor but i didn't tried.
Additionally : some warning about performance problem, unsafe function, nothing big.

Anyway... that was, by far, the easiest problem.

The first error :
Code:
settings.cpp(455): fatal error C1061: compiler limit : blocks nested too deeply
from msdn : Nesting of code blocks exceeds the limit of 128 nesting levels. Simplify nesting.

i simply remplaced the 127th "else if" with a "if", no more "deep nesting" (i didn't knew that a lot of "else if" were "nested blocks" ...)

Next problem :

Code:
1>image.cpp(529): error C2057: expected constant expression
1>image.cpp(529): error C2466: cannot allocate an array of constant size 0
1>image.cpp(529): error C2133: 'Thread' : unknown size
1>image.cpp(530): error C2057: expected constant expression
1>image.cpp(530): error C2466: cannot allocate an array of constant size 0
1>image.cpp(530): error C2133: 'err' : unknown size
1>image.cpp(532): error C2057: expected constant expression
1>image.cpp(532): error C2466: cannot allocate an array of constant size 0
1>image.cpp(532): error C2133: 'thread_param' : unknown size

There exact error is : int NR_THREADS Error: expression must have a constant value

As a workaround, i defined int const NR_THREADS = 2;
and removed : NR_THREADS = get_cpu_count();
But i don't have a good solution

Code:
1>Render3D.cpp(936): error C3861: 'chdir': identifier not found

remplaced by _chdir and included direct.h

i also had to remove unistd.h (don't exist on windows)

1>image.cpp(372): error C2668: 'sqrt' : ambiguous call to overloaded function

There are two pow/sqrt functions, one that takes a float and returns a float, and one that takes a double and returns a double.
So i modified the program that way : double r = sqrt(double(dx * dx + dy * dy));


Now it compile... but doesn't link, with tons of undefined reference to gtk stuff. probably just a project setting problem (hopefully) :)

There is a lot of win32 coder here.
Can someone help me to solve all thoses problems in a clean way ? (so buddy could include all the modifications in the original software and still keep it multiplatform)

thank you :)


Title: Re: Compiling on VS2010 C++ Express
Post by: ker2x on May 14, 2010, 11:27:57 PM
about the linking problem, i just added :
glib-2.0.lib
pangocairo-1.0.lib
pangowin32-1.0.lib
atk-1.0.lib
gdk_pixbuf-2.0.lib
gdk-win32-2.0.lib
pango-1.0.lib
gmodule-2.0.lib
gobject-2.0.lib
gthread-2.0.lib
gtk-win32-2.0.lib
cairo.lib
jpeg.lib

Next and last problem known :

Quote
1>  Generating Code...
1>LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification
1>fractal.obj : error LNK2005: "int const NR_THREADS" (?NR_THREADS@@3HB) already defined in callbacks.obj
1>image.obj : error LNK2005: "int const NR_THREADS" (?NR_THREADS@@3HB) already defined in callbacks.obj
1>interface.obj : error LNK2005: "int const NR_THREADS" (?NR_THREADS@@3HB) already defined in callbacks.obj
1>Render3D.obj : error LNK2005: "int const NR_THREADS" (?NR_THREADS@@3HB) already defined in callbacks.obj
1>settings.obj : error LNK2005: "int const NR_THREADS" (?NR_THREADS@@3HB) already defined in callbacks.obj
1>shaders.obj : error LNK2005: "int const NR_THREADS" (?NR_THREADS@@3HB) already defined in callbacks.obj
1>C:\Users\vbox\Desktop\CS2010-Mandelbulber-win32-0.50 - Copie\src\Release\mandelbulber.exe : fatal error LNK1169: one or more multiply defined symbols found
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

i don't know what to do :(   :'(


Title: Re: Compiling on VS2010 C++ Express
Post by: ker2x on May 15, 2010, 12:00:46 AM
You know what ? forget about VisualStudio.
It works with CodeBlocks and that's good enough  :D


Title: Re: Compiling on VS2010 C++ Express
Post by: cbuchner1 on May 15, 2010, 02:50:31 PM
You know what ? forget about VisualStudio.
It works with CodeBlocks and that's good enough  :D

I suspect your NR_THREADS hack was done in a header file which got included from multiple .cpp files - so an instance of NR_THREADS was created in each .obj file - resulting in a collision during the linking phase


Title: Re: Compiling on VS2010 C++ Express
Post by: knighty on May 15, 2010, 03:08:35 PM
Maybe NR_THREADS should be declared with 'extern' statment in the header file and declared (to be actually allocated) once in one of the c,cpp files. Someting like this in the header:
extern int NR_THREADS;


Title: Re: Compiling on VS2010 C++ Express
Post by: Buddhi on May 16, 2010, 10:58:56 AM
Code:
There exact error is : int NR_THREADS Error: expression must have a constant value

As a workaround, i defined int const NR_THREADS = 2;
and removed : NR_THREADS = get_cpu_count();
But i don't have a good solution

GCC compilator allows to use array declaration with not constant value. I used:
Code:
GThread *Thread[NR_THREADS + 1];
GError *err[NR_THREADS + 1];

For VisualStudio should be changed to:
Code:
GThread **Thread = new GThread*[NR_THREADS + 1];
GError **err = new GError*[NR_THREADS + 1];

Maybe NR_THREADS should be declared with 'extern' statment in the header file and declared (to be actually allocated) once in one of the c,cpp files. Someting like this in the header:
extern int NR_THREADS;
Now there is in Render3D.h:
Code:
extern int NR_THREADS;
and in Render3D:
Code:
int NR_THREADS;
It should be enough. All files which use NR_THREADS value have to include Render3D.h file.

Code:
There is a lot of win32 coder here.
Can someone help me to solve all thoses problems in a clean way ? (so buddy could include all the modifications in the original software and still keep it multiplatform)
This source code is already multi-platform but VisualC++ is completely different than GCC family compilers. To compile this program on Windows you should use MiniGW environment or Cygwin.


Title: Re: Compiling on VS2010 C++ Express
Post by: ker2x on May 17, 2010, 09:44:59 AM
This source code is already multi-platform but VisualC++ is completely different than GCC family compilers. To compile this program on Windows you should use MiniGW environment or Cygwin.

yup  ;D
I wanted to make it compilable on both MinGW and MS VS2010, but i realize that it's a pain in the *bleep*, my bad   :sad1: