数学建模社区-数学中国
标题:
C++调用lingo
[打印本页]
作者:
tomorrow0530
时间:
2011-5-23 12:06
标题:
C++调用lingo
本帖最后由 tomorrow0530 于 2011-5-23 12:07 编辑
/ ]" |- }+ T" G- H/ p/ N0 m, u
0 d5 y% F9 C2 g' Y& m
现需要c++来调用lingo文件
9 D; Z9 d2 J, M& w% f
我用lingo目录下C:\LINGO11\Programming Samples\VC++\**自带的文件,
' f4 n8 r2 Z2 u
新建了一个工程,
" C- |# M) @7 | M1 P9 K
然后**.c文件加入工程,
1 r J \/ |' d/ s5 |; e
然后再把lingo11.lib添加到工程中,
# ~( [' Q7 I8 D7 _1 t3 p
' l4 Q/ e$ C* W7 F+ a2 m* b2 {% ~
但是编译报错!
9 p) m* C2 c2 l8 f( ?9 J; Z
直接编译报:
# B5 u3 k# I, g: N( U) Z' g
75 C:\LINGO11\Programming Samples\VC++\**\**.c invalid conversion from `int (*)(void*, void*, int, char*)' to `void (*)(void*, void*, int, char*)'
1 n3 ~' G0 j7 v3 t
75 C:\LINGO11\Programming Samples\VC++\**\**.c initializing argument 2 of `int LSsetCallbackErrorLng(void*, void (*)(void*, void*, int, char*), void*)'
. K( \5 Y! v+ [- z4 x' T
+ R* P/ _/ L0 n( M
用**目录下的makefile文件编译报:
: ?$ ?+ V: ]: K6 ?+ Z9 b3 ]
CreateProcess((null), cl -c **.c, ...) failed.
! v8 a( Z! _- o0 |. m! l, _) o$ f
系统找不到指定的文件。
% V. t! b, M4 {! |1 K( ^0 O. O' m
C:\LINGO11\Programming Samples\VC++\**\Makefile [Build Error] [**.obj] Error 2
. K$ ?5 H, _' G' e' \9 h+ C
我用的C++编译器是devC++4.9.9.2
, s) N/ ]7 `$ u# o9 t
有人成功过吗?
. i1 H4 e% z4 F% y% p& G
作者:
tomorrow0530
时间:
2011-5-23 12:07
本帖最后由 tomorrow0530 于 2011-5-23 12:08 编辑
6 T9 c9 E s3 H& W- q/ z) v
) l. `/ E" r: o) e) |" B
为什么我输入了s i m p l e变成**了
作者:
tomorrow0530
时间:
2011-5-23 12:14
在直接编译下我把75行的注释后,编译没有错了,但是链接出错了,说明还是没有链接成功
. S, W; L( h% O' ^. T
提示
7 \; l' [* m# O6 T
Compiler: Default compiler
4 b9 U6 M1 A2 J2 U; k v# l
Building Makefile: "C:\LINGO11\Programming Samples\C++\**\Makefile.win"
: K! Y+ l+ s8 F- P+ O+ e
Executing make...
* Q* t) n ^3 N6 I; \" n
make.exe -f "C:\LINGO11\Programming Samples\C++\**\Makefile.win" all
# t8 R- }' |7 ^( T
g++.exe **.o -o "Project1.exe" -L"C:/Dev-Cpp/lib"
" [' ^' S8 m8 k/ K
5 W) s y3 h8 f/ x# v( U/ ?2 F
**.o(.text+0x15c):**.c: undefined reference to `LScreateEnvLng@0'
& `5 t9 x% Z$ r8 m7 l' S. E
**.o(.text+0x1a6):**.c: undefined reference to `LSsetCallbackSolverLng@12'
0 U' r% e; E1 C U
**.o(.text+0x1eb):**.c: undefined reference to `LSopenLogFileLng@8'
3 v2 n) j" R6 ^. ]) S
**.o(.text+0x224):**.c: undefined reference to `LSsetPointerLng@12'
3 \& z/ h: [" }! \9 x+ V3 g
**.o(.text+0x25d):**.c: undefined reference to `LSsetPointerLng@12'
* Y y) ?* p( q5 b2 z1 ]5 M
**.o(.text+0x296):**.c: undefined reference to `LSsetPointerLng@12'
* Y4 L) D* F8 z, R/ t* M4 S
**.o(.text+0x2cf):**.c: undefined reference to `LSsetPointerLng@12'
3 N3 {/ ?) i8 x [- R
**.o(.text+0x308):**.c: undefined reference to `LSsetPointerLng@12'
0 ]& L! v) s6 N! S% ]" }8 G! W
**.o(.text+0x341):**.c: more undefined references to `LSsetPointerLng@12' follow
* ?; e" T& o% E
**.o(.text+0x3bf):**.c: undefined reference to `L**ecuteScriptLng@8'
, U% S7 p$ a5 |$ {" ]
**.o(.text+0x3e1):**.c: undefined reference to `LScloseLogFileLng@4'
: h) m" u3 c9 @1 t m8 G6 ]6 ?
**.o(.text+0x460):**.c: undefined reference to `LSdeleteEnvLng@4'
5 N: v5 O: K" A+ }& k/ s
collect2: ld returned 1 exit status
4 E. k. ~$ u: @# }
0 ]; @9 r2 o: w$ U$ I
make.exe: *** [Project1.exe] Error 1
% T6 c( r: ]6 t9 J' w1 l) M
+ k/ e! Q( C F" _5 k* a: R6 e
Execution terminated
8 d8 U4 [- V" U1 l0 |8 U E
作者:
tomorrow0530
时间:
2011-5-23 15:20
本帖最后由 tomorrow0530 于 2011-5-23 15:21 编辑
! \- g$ R+ L7 T
0 v7 q, D( t6 ?. D/ K
Compiler: Default compiler
# ^2 C, v: r( o3 _# z" f5 l
Building Makefile: "C:\LINGO11\Programming Samples\C++\s imple\Makefile.win"
( x" p9 m8 d& A o
Executing make...
# l' V7 I% F4 @ f) W
make.exe -f "C:\LINGO11\Programming Samples\C++\s imple\Makefile.win" all
. F: @( `( O+ ~8 E
g++.exe -c S imple.c -o S imple.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I"../../"
* W: f. c- j5 ~/ x# K% q
- R$ B& i0 y. U7 {8 C! k7 s
g++.exe S imple.o -o "Project1.exe" -L"C:/Dev-Cpp/lib" -L"C:/LINGO11/Programming Samples" ../../Lingd11.lib
/ ?: ^, e4 _4 A1 u# t+ n
( |5 \4 S: e& E+ y
S imple.o(.text+0x15c):**.c: undefined reference to `LScreateEnvLng@0'
: t: \' O) a7 G3 I8 p
S imple.o(.text+0x1a6):**.c: undefined reference to `LSsetCallbackSolverLng@12'
5 r; L) @6 _' G6 d7 H, [( D
S imple.o(.text+0x1eb):**.c: undefined reference to `LSopenLogFileLng@8'
9 W' S7 S9 h# {0 t* A
S imple.o(.text+0x224):**.c: undefined reference to `LSsetPointerLng@12'
1 i6 D6 F) h9 q) }6 R
**.o(.text+0x25d):**.c: undefined reference to `LSsetPointerLng@12'
5 I# f3 u" p7 d# @ d* y
**.o(.text+0x296):**.c: undefined reference to `LSsetPointerLng@12'
3 b5 c4 _7 x) i. F0 Z" k
**.o(.text+0x2cf):**.c: undefined reference to `LSsetPointerLng@12'
4 E" F$ r- q" M9 B$ d6 S/ V: B) F
**.o(.text+0x308):**.c: undefined reference to `LSsetPointerLng@12'
N9 x; Y, ^) s) a: O& U4 u
**.o(.text+0x341):**.c: more undefined references to `LSsetPointerLng@12' follow
1 B/ M; n% t8 a
**.o(.text+0x3bf):**.c: undefined reference to `L**ecuteScriptLng@8'
" F1 ]; e% ^. s9 l8 X
**.o(.text+0x3e1):**.c: undefined reference to `LScloseLogFileLng@4'
7 n$ ]5 a+ O6 ^$ b% `6 _
**.o(.text+0x460):**.c: undefined reference to `LSdeleteEnvLng@4'
5 H2 G) m3 t* L1 h% G1 f
collect2: ld returned 1 exit status
) _& ?( F7 F9 F; f
9 v/ i) Z% X4 H% I" d2 x2 _/ [; K
make.exe: *** [Project1.exe] Error 1
" ~0 i8 h- K% K9 G
. f: D4 r D' W
Execution terminated
! T/ {' o( `* n5 O/ |& E
6 X, _& f7 z- ~8 ~
这次的编译结果,应该是s imple.o文件已经生成,但是生成project1.exe的时候出错了
作者:
alair004
时间:
2012-2-6 15:00
囧了,下了无数不知道用哪个有用
4657807944840288
欢迎光临 数学建模社区-数学中国 (http://www.madio.net/)
Powered by Discuz! X2.5