C++ GDX examples

133 views
Skip to first unread message

Eduardo

unread,
Jul 19, 2011, 6:12:11 PM7/19/11
to gamsworld
Hi,

I am interested in building a tool in c++ that has GDX reading and
writing capabilities. I tried to compile the examples that are
provided in the "apifiles" folders with g++ but I haven't had any
luck. Are those files only compatible with Visual C++?

Thanks in advance,

Eduardo

Lutz Westermann

unread,
Jul 21, 2011, 6:19:15 AM7/21/11
to gams...@googlegroups.com
Eduardo,

I don't know on what platform you are working on, but here is what I did
on 32bit Unix to compile example1.cpp with g++:

g++ -o example1.out -m32 example1.cpp ../gdx/gdxco.cpp ../gdx/gdxcc.c
-I../gdx -I../common -ldl

Does this help?

Best regards,
Lutz


--
Lutz Westermann LWest...@gams.com
GAMS Development Corporation GAMS Software GmbH
1217 Potomac St. NW, Eupener Str. 135-137
Washington DC, 20007, USA 50933 Cologne, Germany
Fon/Fax: +1 202 342-0180/1 Fon/Fax: +49 221 949-9170/1
http://www.gams.com http://www.gams.de

Eduardo

unread,
Jul 21, 2011, 10:24:32 AM7/21/11
to gamsworld
Hi Lutz,

Thanks for your answer. I realize that I should have given more
details... I'm working on Windows 7 and using the mingw-g++ compiler.
It's included in the Qt4, which I eventually want to use to build a
GUI that can export/import GDX files.

I'm using both of the following commands:

mingw32-g++ -o example1.out -m32 example1.cpp ../gdx/gdxco.cpp ../gdx/
gdxcc.c -I../gdx -I../common -ldl
mingw32-g++ example1.cpp ../gdx/gdxco.cpp ../gdx/gdxcc.c -I../gdx -I../
common


And I'm getting the following errors and warnings:



../gdx/gdxcc.c: In function 'void* loadSym(HINSTANCE__*, const char*,
char**)':
../gdx/gdxcc.c:456: error: invalid conversion from 'int (*)()' to
'void*'
../gdx/gdxcc.c: In function 'int XLibraryLoad(const char*, char*,
int)':
../gdx/gdxcc.c:538: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:539: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:540: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:541: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:547: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:548: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:561: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:562: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:563: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:564: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:565: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:566: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:567: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:568: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:569: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:570: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:571: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:572: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:573: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:574: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:575: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:576: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:577: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:578: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:579: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:580: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:581: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:582: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:583: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:584: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:585: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:586: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:587: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:588: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:589: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:590: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:591: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:592: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:593: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:594: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:595: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:596: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:597: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:598: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:599: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:600: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:601: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:602: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:603: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:604: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:605: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:606: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:607: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:608: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:609: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:610: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:611: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:612: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:613: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:614: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:615: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:616: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:617: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:618: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:619: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:620: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:621: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:622: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:623: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:624: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:625: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:626: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:627: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:628: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:629: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:630: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:631: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:632: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:633: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:634: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:635: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:636: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:637: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:638: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:639: warning: deprecated conversion from string
constant to 'char *'
../gdx/gdxcc.c:640: warning: deprecated conversion from string
constant to 'char *'


Thanks,
Eduardo




On Jul 21, 4:19 am, Lutz Westermann <lwesterm...@gams.com> wrote:
> Eduardo,
>
> I don't know on what platform you are working on, but here is what I did
> on 32bit Unix to compile example1.cpp with g++:
>
> g++ -o example1.out -m32 example1.cpp ../gdx/gdxco.cpp ../gdx/gdxcc.c
> -I../gdx -I../common -ldl
>
> Does this help?
>
> Best regards,
> Lutz
>
> On 7/19/2011 6:12 PM, Eduardo wrote:
>
> > Hi,
>
> > I am interested in building a tool in c++ that has GDX reading and
> > writing capabilities. I tried to compile the examples that are
> > provided in the "apifiles" folders with g++ but I haven't had any
> > luck. Are those files only compatible with Visual C++?
>
> > Thanks in advance,
>
> > Eduardo
>
> --
> Lutz Westermann                     LWesterm...@gams.com

Lutz Westermann

unread,
Jul 21, 2011, 12:22:08 PM7/21/11
to gams...@googlegroups.com
Eduardo,

I just installed g++ on my Windows 7 machine. This is the version I have
now:

bash-2.02$ g++ --version
egcs-2.91.57

With that I did

g++ -o example1.exe example1.cpp ../gdx/gdxco.cpp ../gdx/gdxcc.c -I
./gdx -I../common

and that worked. I tried to follow the error you got (../gdx/gdxcc.c: In

function 'void* loadSym(HINSTANCE__*, const char*, char**)':
../gdx/gdxcc.c:456: error: invalid conversion from 'int (*)()' to

'void*'), but if I look at line 456 in gdxcc.c that is not in the
function loadSym. And when I look at the function loadSym I cannot find
the conversion that is mentioned in the error message. Are you using the
most recent version of GAMS (23.7) and the appropriate API files?

Best,
Lutz


--
Lutz Westermann LWest...@gams.com


GAMS Development Corporation GAMS Software GmbH
1217 Potomac St. NW, Eupener Str. 135-137
Washington DC, 20007, USA 50933 Cologne, Germany

Eduardo

unread,
Jul 22, 2011, 2:20:08 PM7/22/11
to gams...@googlegroups.com
Lutz,

I was using an older version of GAMS. I downloaded the most recent one and tried again.

I am compiling with MinGW, which is included with the Qt installation. I think you can download it by itself here:
http://get.qt.nokia.com/misc/MinGW-gcc440_1.zip

I checked the version and got this:

>g++ --version
g++ (GCC) 4.4.0
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Executing the same code that you suggested returned the same errors, but the line numbers are slightly different.

>g++ -o example1.exe example1.cpp ../gdx/gdxco.cpp ../gdx/gdxcc.c -I../gdx -I../common

../gdx/gdxcc.c: In function 'void* loadSym(HINSTANCE__*, const char*, char**)':
../gdx/gdxcc.c:436: error: invalid conversion from 'int (*)()' to 'void*'

../gdx/gdxcc.c: In function 'int XLibraryLoad(const char*, char*, int)':
../gdx/gdxcc.c:542: warning: deprecated conversion from string constant to 'char*'

../gdx/gdxcc.c:543: warning: deprecated conversion from string constant to 'char*'
../gdx/gdxcc.c:544: warning: deprecated conversion from string constant to 'char*'
../gdx/gdxcc.c:545: warning: deprecated conversion from string constant to 'char*'
../gdx/gdxcc.c:551: warning: deprecated conversion from string constant to 'char*'
../gdx/gdxcc.c:552: warning: deprecated conversion from string constant to 'char*'
../gdx/gdxcc.c:559: warning: deprecated conversion from string constant to 'char*'
../gdx/gdxcc.c:560: warning: deprecated conversion from string constant to 'char*'

[Warning repeated for all the lines in between]


../gdx/gdxcc.c:638: warning: deprecated conversion from string constant to 'char*'


Thanks for your help. I will keep trying...

Eduardo

Lutz Westermann

unread,
Jul 25, 2011, 12:17:14 PM7/25/11
to gams...@googlegroups.com
Eduardo,

Attached there is a modified version of gdxcc.c. Can you try to replace
yours in <GAMS>\apifiles\gdx with this one and try it again? You will
see that I modified the function XLibraryLoad and LoadSym.

Best regards,
Lutz

> --
> You received this message because you are subscribed to the Google
> Groups "gamsworld" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/gamsworld/-/U8WkJdzXVLwJ.
> To post to this group, send email to gams...@googlegroups.com.
> To unsubscribe from this group, send email to
> gamsworld+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/gamsworld?hl=en.

gdxcc.c

Eduardo

unread,
Jul 29, 2011, 7:06:43 PM7/29/11
to gams...@googlegroups.com
Lutz,

Thanks for your help. I had to do one more change (delete the "(intptr_t)" that you added in lines 454 and 455) and I got it working.

I also managed to get example2 working, with similar changes in "optcc.c" and "gamsxcc.c". I have attached all my revisions of those files. I hope it's OK, otherwise I'll remove them.

I got some warning messages when I compiled the second example, but it seems to execute just fine. Thanks again for your help, I am not that familiar with C.

Eduardo

________________

>g++ example2.cpp ../gdx/gdxco.cpp ../gdx/gdxcc.c ../opt/optco.cpp ../opt/optcc.c ../gamsx/gamsxco.cpp ../gamsx/gamsxcc.c -I../gdx -I../opt -I../gamsx -I../common
example2.cpp: In function 'int WriteModelData(std::string)':
example2.cpp:47: warning: cannot pass objects of non-POD type 'struct std::string' through '...'; call will abort at runtime
example2.cpp:50: warning: cannot pass objects of non-POD type 'struct std::string' through '...'; call will abort at runtime
example2.cpp:57: warning: cannot pass objects of non-POD type 'struct std::string' through '...'; call will abort at runtime
example2.cpp:60: warning: cannot pass objects of non-POD type 'struct std::string' through '...'; call will abort at runtime
example2.cpp: In function 'int CallGams(std::string)':
example2.cpp:82: warning: deprecated conversion from string constant to 'char*'example2.cpp: In function 'int ReadSolutionData(std::string)':
example2.cpp:103: warning: cannot pass objects of non-POD type 'struct std::string' through '...'; call will abort at runtime
example2.cpp:118: warning: cannot pass objects of non-POD type 'struct std::string' through '...'; call will abort at runtime
example2.cpp:133: warning: cannot pass objects of non-POD type 'struct std::string' through '...'; call will abort at runtime
example2.cpp:136: warning: cannot pass objects of non-POD type 'struct std::string' through '...'; call will abort at runtime
optcc.c
gdxcc.c
gamsxcc.c
Reply all
Reply to author
Forward
0 new messages