Challenges master!

Category: C/C++ -> C++ Author: wang554345806 Date: 2005-10-26 09:08:05
2005-10-26 09:08:05
Help (crash, huh, huh, do not worry read) look at the recent mixed programming under linux gcc, I wrote a small example program, as
/ / / / c
int ; main (void)
int n = 1;
extern void cdf_ (int * num);
cdf_ (& n);
printf ("% d \ n", n);
return 1;
CCCC ; fortran
subroutine cdf (num)
num = 10;
# makefile
obj1 = main.c # represent many. c, not to enumerate the
obj2 = cdf.for
obj3 = main.o
obj4 = cdf.o
myexe: $ (obj3) $ (obj4)
gfortran *. o-o myexe
%. o:%. c
gcc-c *. c
%. o:%. for
gfortran-c *. for
rm myexe *. o

# # # # # # # # # # if c is c, the normal file, the program can be run to generate myexe,
when the corresponding file are changed to the time c + + (. c-> ;. cpp, gcc-> g+ +) is generated when the connection can not myexe
given as follows:
main.o (. text + ox28) In function 'main:
: undefined reference to 'cff_ (int *)'
main.o (. gun.linkonce.d.DW.ref.__gxx_personality_v0 + ox0): undefined reference to
. __gxx_personality_v0 '
collect: ld returned 1 exit status
the pass key is c, c + +. cpp file will not work, it is a headache
2005-10-26 09:14:05
Khan, actually there fortran, rookie drifting, pure support!
2005-10-26 09:26:24
'cff_ (int *)
2005-10-26 09:29:11
Could that be a linkage problem? Do you want to add an extern "C"
2005-10-26 09:44:26
transform the old project Yeah, big brother ideas to c + + have to do c, too much work, but it will not do so, I do not believe, so many people on the Internet can not understand this hit the
2005-10-26 10:00:37

No, you said it was the xp vc, linux under gcc will complain, really quickly master the challenges into someone to accompany, I do not know that someone can not beat the act? ! Oh
2005-10-26 10:18:53
extern "C" into the main function of the above, do not put inside.
2005-10-26 10:38:37
Could I have this little problem nobody answered rookie got up? I have a week in the online Hou
2005-10-26 10:47:15
Another one others give you answer, you did not respond, did not care still here complaining.
2005-10-26 11:01:30

I also tried, also tried to build a separate header file, it was suggested that I use class encapsulates the call, or not
2005-10-26 11:04:31
other posts I have looking at that approach also tried
2005-10-26 11:11:30
I made a six programforge stickers, four other sites and can not be made, and then I see, however made, but basically tried , and back could not solve I have to summarize, so after you, like me, full of where to find
2005-10-26 11:30:04

# include <iostream>

using namespace std;

extern "C" {
void fortfunc_ (int * ii, float * ff);

main ()

; int ii = 5;
float ff = 5.5;

fortfunc_ (& ii, & ff );

return 0;

subroutine fortfunc (ii, ff)
integer ii
; real * 4 ff

write (6,100) ii, ff
100 ; format ('ii =', i2, 'ff =', f6.3)


* f77-c testF.f
* g+ +-c testC.cpp
* g+ +-o test testF.o testC.o-lg2c

Run:. / test

ii = 5 ff = 5.500
2005-10-26 11:38:49

I saw both, for a time did not empty shot replies, I do not think the version of gcc 3.4.6 is not f cpp tune it? This is a bit too ......
2005-10-26 11:46:22
cpp will become after you posted about the final version to see if there is any negligence in a small place.
2005-10-26 11:49:50
Thank dispensers, I try again, mainly in Beijing on business, this place can not break the internet, I can only Paowang Ba, but could not get on the plate. Not have to go back to thank you. Also ask a question, I would like to know under normal circumstances the default connected to those libraries are useful to give a list of do? I can not just random people on the server again. I doubt very much that they had unloaded what library file.
2005-10-26 12:00:07
still waiting for you to try it
2005-10-26 12:03:28
can challenge a few statements on this master, you do not understand is the master answer it?
give concrete. Pack your name. C,. Cpp have to pass.

#include <stdio.h>
#ifdef __cplusplus
extern "C" 
void cdf_(int * num);
int main(void)
int n=1;
return 1;

,.c, cpp  。
#ifdef __cplusplus
extern "C" 
void cdf_(int * num);
 void cdf_(int * num)

2005-10-26 12:16:26
I can only handwritten estimated and forth to night, and back Gonggongzhengzheng finished copy paste up (What's this TMD s the?!), helpless. To do buttoned contact?
2005-10-26 12:29:22
17 F, I know what you mean, this did not seem to matter much

Page 1 of 2    «  »