J
JeffCameron
Hi everyone. I am using the latest MinGW that comes with Dev-C++ for
Windows. I am getting an impossible linker error when I try to call
some functions from a library that I wrote. I am avsolutely sure that
the library is linked. I would greatly appreciate a reply from someone
who knows the solution to this problem.
Here is a simplified version of my problem. In order to reproduce the
linking error that I am talking about, use the following steps:
- Use Dev-C++ to create a static library using hello.c and hello.h
- Create a new console application project with main.cpp as its
main source file
- Go to Project -> Project Options -> Parameters and click the Add
Library or Object button
- Add the library that was created in step 1
- Attempt to compile main.cpp
The error that I get is:
[Linker error] undefined reference to 'helloWorld()'
Here are the source files:
### hello.c ###
#include "hello.h"
void helloWorld()
{
printf("Hello World!\n");
}
### hello.h ###
#ifndef HELLO_H
#define HELLO_H
#include <stdio.h>
void helloWorld();
#endif
### main.cpp ###
#include "hello.h"
int main()
{
helloWorld();
return 0;
}
I would greatly appreciate a reply from someone who knows the solution
to this problem.
Jeff Cameron
Windows. I am getting an impossible linker error when I try to call
some functions from a library that I wrote. I am avsolutely sure that
the library is linked. I would greatly appreciate a reply from someone
who knows the solution to this problem.
Here is a simplified version of my problem. In order to reproduce the
linking error that I am talking about, use the following steps:
- Use Dev-C++ to create a static library using hello.c and hello.h
- Create a new console application project with main.cpp as its
main source file
- Go to Project -> Project Options -> Parameters and click the Add
Library or Object button
- Add the library that was created in step 1
- Attempt to compile main.cpp
The error that I get is:
[Linker error] undefined reference to 'helloWorld()'
Here are the source files:
### hello.c ###
#include "hello.h"
void helloWorld()
{
printf("Hello World!\n");
}
### hello.h ###
#ifndef HELLO_H
#define HELLO_H
#include <stdio.h>
void helloWorld();
#endif
### main.cpp ###
#include "hello.h"
int main()
{
helloWorld();
return 0;
}
I would greatly appreciate a reply from someone who knows the solution
to this problem.
Jeff Cameron