LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-26-2004, 01:22 PM   #1
sheds
Member
 
Registered: Oct 2004
Location: Costa Rica
Distribution: Mandrake 9.1
Posts: 30

Rep: Reputation: 15
C Programming


I have a small problem with the include clause. The fucntions i have declared inside the .h files pop up an "unresolved function-name". Its like the include is not there at all. Any ideas anyone. BTW, other questions can be posted here as well.
 
Old 10-26-2004, 01:29 PM   #2
Homer Jay
LQ Newbie
 
Registered: Dec 2003
Location: Berlin/Germany
Distribution: Debian
Posts: 22

Rep: Reputation: 15
Well, if the compiler complains about some code inside that .h file,
then it must have been included.
A little bit of the offending code might be helpful...
 
Old 10-26-2004, 01:54 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Yep, as homer j said ... if you get something about
unresolved you're already past the compile, the header
has been inlcuded, but the linker can't find the object
code that matches the funtion the header described.

And more info would definitely help in assessing
this problem ;) ... e.g. a copy and paste of the error
message would be helpful.


Cheers,
Tink
 
Old 10-26-2004, 02:05 PM   #4
sheds
Member
 
Registered: Oct 2004
Location: Costa Rica
Distribution: Mandrake 9.1
Posts: 30

Original Poster
Rep: Reputation: 15
The functions are declared yet not implemented in the .h file. I have another file with the exact same name but with the extension .pc, where the fucntion declared in the .h is implemented.

#include "atcli031.h" // this is the .h file include in the file that uses the fucntion
extern int atcli031_Consulta_conceptos_recibo_detalle (atcli031_conceptos_recibo_detalle_Arg * , char** );
//this is the function declared here in the .h file

//The implementation is in the atcli031.pc file like follows:
extern int atcli031_Consulta_conceptos_recibo_detalle(atcli031_conceptos_recibo_detalle_Arg *lsp_conceptos_recibo_detalle_Arg, char **pcp_Out )
{
int li_Status;
char * lcp_Out;
long ll_Contador = 0;
atcli031_conceptos_recibo_detalle *lsp_conceptos_recibo_detalle;
// the rest of the code goes here
return 0;
}

//After this, i include #include "atcli031.h" in another file called call_031.c like follows
#include "fgen.h"
#include "atcli031.h"
//Then i try to call the function atcli031_Consulta_conceptos_recibo_detalle like this
int main()
{
char* ll_Nis_Rad = "3231659";
char* ll_Sec_Nis = "1";
char* ll_Sec_Rec = "0";

char *lcp_bloque_atcli031;
atcli031_conceptos_recibo_detalle_Arg slp_atcli031;

/*ESTRUCTURA PARA LA FUNCION ATCLI031*/

slp_atcli031.l_secrec = ll_Sec_Rec;
slp_atcli031.l_nisrad = ll_Nis_Rad;
slp_atcli031.l_secnis = ll_Sec_Nis;
strcpy(slp_atcli031.fh_ffact,lf_Ffact);
if((atcli031_Consulta_conceptos_recibo_detalle(&slp_atcli031,&lcp_bloque_atcli031)) < 0 )
return -1;
else
{
printf("Exito");
return 1;
}
}

The ERROR says (compiling with cc call_031.c):
ld:
Unresolved:
atcli031_Consulta_conceptos_recibo_detalle

Last edited by sheds; 10-26-2004 at 02:15 PM.
 
Old 10-26-2004, 02:20 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
You'll need to compile that .pc file first, and add
the object file to the command-line for the real thing,
e.g.

gcc real-file.c atcli031.o -o real-file

As we said - it compiles fine, it just doesn't link,
and there's nothing wrong with the code, just with
the steps you try for linking.


Cheers,
Tink
 
Old 10-26-2004, 02:46 PM   #6
sheds
Member
 
Registered: Oct 2004
Location: Costa Rica
Distribution: Mandrake 9.1
Posts: 30

Original Poster
Rep: Reputation: 15
I have no .o files, how do i generate them?

call_031.c is the file i am trying to compile. Inside i have an include of #include "atcli031.h", that contains only a definition of the function "atcli031_Consulta_conceptos_recibo_detalle(atcli031_conceptos_recibo_detalle_Arg *lsp_conceptos_recibo_detalle_Arg, char **pcp_Out )". The implementation of this function is in a .pc file. I guess you are right, i need to link the .pc file with the .h file and then the .h file with call_031.c. The thing is i have no .o files anywhere. Am i completely lost here?

Here is what i wrote in the command line:
cc call031.c atcli_031.o -o call031

I got some warnings that have nothing to do with the issue. But here is the full description of the other problem i get regarding the function:
ld:
Can't open: atcli031.o (No such file or directory)
How do i create the .o file?

Last edited by sheds; 10-26-2004 at 02:53 PM.
 
Old 10-26-2004, 03:01 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
What exactly is that .pc file?

Is it C-source with a funny name, or is it what
package-config would be using? In the latter
case it's not quite what you need (or need to do).

If it's a C source file you can compile it using
gcc atcli031.pc -c
which will create atcli031.o ....


Cheers,
Tink
 
Old 10-26-2004, 11:28 PM   #8
sheds
Member
 
Registered: Oct 2004
Location: Costa Rica
Distribution: Mandrake 9.1
Posts: 30

Original Poster
Rep: Reputation: 15
It's actually pro c code. It's c. I have no idea why it is set up this way, but i have to work with it. Definitions of structs and functions in .h files and the implementation in .pc files. The code i put on one of my replies shows how the atcli031.pc file looks like, and how it is called from the .c file, the one i am compiling, or trying. Jejejeje.
 
Old 10-26-2004, 11:43 PM   #9
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
And, will it compile in the way I suggested? :)


Cheers,
Tink
 
Old 10-27-2004, 12:39 PM   #10
sheds
Member
 
Registered: Oct 2004
Location: Costa Rica
Distribution: Mandrake 9.1
Posts: 30

Original Poster
Rep: Reputation: 15
The terminal i use at work does not accept gcc, only cc. I came home and tried the gcc and it does work. What i understand you're saying is to compile the .pc file, that creates the .o file, and then compile the .c file with the .o file option, am i correct?
 
Old 10-27-2004, 12:42 PM   #11
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Yep - that should do the trick.


Cheers,
Tink
 
Old 10-28-2004, 05:34 PM   #12
sheds
Member
 
Registered: Oct 2004
Location: Costa Rica
Distribution: Mandrake 9.1
Posts: 30

Original Poster
Rep: Reputation: 15
Here at work i can't use gcc. What i need to do now is generate a .o file from a .pc file. How do i do this?
 
Old 10-28-2004, 05:47 PM   #13
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
man cc
for details on generating intermediate object-files.

I have no clue :)


Cheers,
Tink
 
Old 10-28-2004, 09:27 PM   #14
sheds
Member
 
Registered: Oct 2004
Location: Costa Rica
Distribution: Mandrake 9.1
Posts: 30

Original Poster
Rep: Reputation: 15
I've worked out another solution for the first problem, but no i want to start relearning C at home, and i want to use the mysql engine that i read comes with mandrake. Or maybe i read that wrong. Can i set up mysql database on mandrake and start connecting with C?

BTW, i have the simple "Hello World example" and i get a damn warning i have no idea what it means.

Here's the code and warning.

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <assert.h>

main()
{
//array_ini();
int arr[5]={1,2,3,4,5};
printf("WTF?\n");
}

hola.cc:12:2: warning: no newline at end of file

Thanks Tink, seems u r the only one reading this thread. Jejeje.
 
Old 10-28-2004, 09:58 PM   #15
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
Quote:
Can i set up mysql database on mandrake and start connecting with C?
Yes.

Quote:
hola.cc:12:2: warning: no newline at end of file
The error is likely caused by your editor. What editor did you use. Try to put a few newlines at the end of the file.

Quote:
Thanks Tink, seems u r the only one reading this thread. Jejeje
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
which programming language is used to do tcp/ip programming?? gajaykrishnan Linux - Networking 9 12-21-2012 05:16 AM
im new to programming but..... boxerboy Programming 6 08-26-2005 06:17 AM
Difference between Top Down programming & Bottom up programming minil Programming 1 06-17-2005 02:42 AM
C programming oranj Linux - Networking 1 12-07-2004 12:40 AM
Qt Programming... jinksys Programming 1 08-06-2003 04:33 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration