This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Simple Cygwin Application Linking Problem


Hello,

Iâm pretty new to this whole Cygwin stuff and I have a problem building an application to an executable.

So letâs start with my little c program.

#include <test.h>


int main (void){


      printf("Hello World");
      test();
      return 0;
      
}

int test(void){

      return 0;
}
My header file is pretty simple and looks like this.

int main(void);
int test();

I just included it for screwing around with makefiles and using files that are not in the same directory, so that I had to work with path declarations.

My makefile looks as follows:

#INCLUDES ABSOLUTE
INCNETSNMPABS     = C:/cygwin/home/MJaeger/net-snmp-5.5/include   
INCCYGSTDABS      = C:/cygwin/usr/include             

#INCLUDES RELATIVE TO MAKEFILE 
SOURCEHEADERREL   = ../Headers/

#INCLUDE HEADER COMPILATION
HCOMP             = -I$(INCNETSNMPABS) -I$(INCCYGSTDABS) -I$(SOURCEHEADERREL)


#SOURCES RELATIVE TO MAKEFILE
SOURCEFILEREL           = ../Source/test.c


#LIBRARIES ABSOLUTE
LIBNETSNMPABS     = C:/cygwin/home/MJaeger/net-snmp-5.5/snmplib/
LIBCYGW32APIABS   = C:/cygwin/lib/w32api
LIBCYGSTDABS      = C:/cygwin/usr/include/d/3.4.4/std/c
LIBCYGDLLABS      = C:/cygwin/bin

#LINKER LIBRARY COMPILATION
LCOMP = -L $(LIBNETSNMPABS) -L $(LIBCYGW32APIABS) -L $(LIBCYGSTDABS) -L $(LIBCYGDLLABS)  


target.o: $(SOURCEFILEREL) $(SOURCEHEADERREL)/test.h
      gcc -o target.o $(HCOMP) -c $(SOURCEFILEREL)  
      



test.exe: target.o
      ld $(LCOMP) target.o



When calling make target.o, no error occurs. The file is created and everything seems fine. But when Iâm calling make test.exe the following error occurs:

target.o:test.c(.text+0x12): undefined reference to â__mainâ
target.o:test.c(.text+0x1e): undefined reference to âprintfâ
make: *** [test.exe] Error 1

As I said Iâm pretty new to this Cygwin stuff and Iâm also new to writing makefiles, thatâs why I just want to create a simple example.

To me it seems that the linker does not know enough library files. 
Another problem is of course, since Iâm not so familiar with this stuff, Iâm not even sure what to search for, so maybe someone can provide me with new knowledge or give me some hints so that I know in which topic, or sub topic I have to gain more knowledge.

Cheers and regards
Michael

 

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]