codeapp icon indicating copy to clipboard operation
codeapp copied to clipboard

Trouble in separating functions and declarations.

Open zzl-learner opened this issue 4 years ago • 10 comments

After receiving your email that local C/C++ complier is available yesterday, I tried to finish my homework with it. But here are some problems. When I tried to separate functions and declarations by writing them in separate documents (.h & .cpp), It appeared doesn’t work. From the command I guess it might be a link error, but I have no idea how to fix it. Here are some pictures of this problem. IMG_0266

zzl-learner avatar Jul 06 '21 06:07 zzl-learner

IMG_0265

zzl-learner avatar Jul 06 '21 06:07 zzl-learner

IMG_0263

zzl-learner avatar Jul 06 '21 06:07 zzl-learner

Hello. For multi-file program, you'll need to compile each file individually and link them together. In your case, you'll need to use the following commands.

clang++ main.cpp -c
clang++ func.cpp -c
clang++ main.o func.o 

and use ./a.out to execute.

Let me know if it works.

bummoblizard avatar Jul 06 '21 06:07 bummoblizard

Hello. For multi-file program, you'll need to compile each file individually and link them together. In your case, you'll need to use the following commands.


clang++ main.cpp -c

clang++ func.cpp -c

clang++ main.o func.o 

and use ./a.out to execute.

Let me know if it works.

Thank you so much for it does work! But I wonder if you could make this app do this job automatically in the future? And I also find a small bug. When I typed words below and finished, the keyboard doesn't appear up in the document so I can't edit the document.

zzl-learner avatar Jul 06 '21 06:07 zzl-learner

Great! I'm glad it worked. I will try to fix this problem in the next release.

bummoblizard avatar Jul 06 '21 06:07 bummoblizard

Great! I'm glad it worked. I will try to fix this problem in the next release.

thank you so much

zzl-learner avatar Jul 06 '21 06:07 zzl-learner

Hi, it seems I have the same issue coding in C. I would guess the commands are different than the one used for C++. Can you help me ?

Nrvax avatar Oct 13 '23 10:10 Nrvax

Hi, it seems I have the same issue coding in C.

I would guess the commands are different than the one used for C++.

Can you help me ?

Replace clang++ with clang. Clang++ is for compiling C++ programs.

bummoblizard avatar Oct 13 '23 10:10 bummoblizard

Thank you, I am getting these warnings. Do you now what they are about ? image

Nrvax avatar Oct 13 '23 10:10 Nrvax

Actually, I just forgot to execute the program the way you showed. It is working just fine. Thanks a lot !

Nrvax avatar Oct 13 '23 10:10 Nrvax