Using my own library : implicit declaration of function

Firstly, I’d like to thanks you in advance for the time you’ll take to help me out. If I may suggest you, you can try reproduce my problem. Don’t try to read the makefiles if you don’t feel it’ll help you to understand my problem.

Also, I’d like to point out the fact I did a lot of researches and I don’t have find any solution.

My Environment


  • Eclipse (with CDT)
  • Windows (cygwin) (but I also tried on Ubuntu)

I want to use my own (shared) library in a project.

My Setup


My Shared Library

mylib.h

#ifndef MYLIB_H_
#define MYLIB_H_

extern int foo();

#endif /* MYLIB_H_ */

mylib.c

#include "mylib.h"

extern int foo() {
    return 1;
}

My Project

I added my library as a reference :

Project Properties – C/C Generals – Paths and Symbols – References (tab) – Check off mylib (Active)

foo.c

#include <stdlib.h>

int main(int argc, char **argv) {
    return foo();
}

Problem


I’m getting implicit declaration of function ‘foo’ [-Wimplicit-function-declaration] warning when I build my project. This warning only occurs when I build my project while my library project has nothing to build (because it hasn’t been modified since the last build).

Console output

Info: Internal Builder is used for build
gcc -std=c99 "-ID:\\Users\\cmourgeo\\maximo workspace\\mylib" -O0 -g3 -Wall -c -fmessage-length=0 -o "src\\uselib.o" "..\\src\\uselib.c"
..\src\uselib.c: In function 'main':
..\src\uselib.c:12:2: warning: implicit declaration of function 'foo' [-Wimplicit-function-declaration]
  return foo();
  ^
gcc "-LD:\\Users\\cmourgeo\\maximo workspace\\mylib\\Debug" -o uselib.exe "src\\uselib.o" -lmylib

Should I provide eclipse my own makefiles ? (under C/C++ / Builder Settings)

Main Project makefile (auto-generated)

################################################################################
# Automatically-generated file. Do not edit!
################################################################################

-include ../makefile.init

RM := rm -rf

# All of the sources participating in the build are defined here
-include sources.mk
-include src/subdir.mk
-include subdir.mk
-include objects.mk

ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
endif

-include ../makefile.defs

# Add inputs and outputs from these tool invocations to the build variables 

# All Target
all: uselib.exe

dependents:
    -cd D:/Users/cmourgeo/maximo\ workspace/mylib/Debug && $(MAKE) all

# Tool invocations
uselib.exe: $(OBJS) $(USER_OBJS) D:/Users/cmourgeo/maximo\ workspace/mylib/Debug/mylib.dll
    @echo 'Building target: $@'
    @echo 'Invoking: Cygwin C Linker'
    gcc -L"D:\Users\cmourgeo\maximo workspace\mylib\Debug" -o "uselib.exe" $(OBJS) $(USER_OBJS) $(LIBS)
    @echo 'Finished building target: $@'
    @echo ' '

# Other Targets
clean:
    -$(RM) $(EXECUTABLES)$(OBJS)$(C_DEPS) uselib.exe
    [email protected] ' '

.PHONY: all clean dependents
.SECONDARY:
D:/Users/cmourgeo/maximo\ workspace/mylib/Debug/mylib.dll:

-include ../makefile.targets

Library makefile (auto-generated)

################################################################################
# Automatically-generated file. Do not edit!
################################################################################

-include ../makefile.init

RM := rm -rf

# All of the sources participating in the build are defined here
-include sources.mk
-include src/subdir.mk
-include subdir.mk
-include objects.mk

ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
endif

-include ../makefile.defs

# Add inputs and outputs from these tool invocations to the build variables 

# All Target
all: mylib.dll

# Tool invocations
mylib.dll: $(OBJS) $(USER_OBJS)
    @echo 'Building target: $@'
    @echo 'Invoking: Cygwin C Linker'
    gcc -shared -o "mylib.dll" $(OBJS) $(USER_OBJS) $(LIBS)
    @echo 'Finished building target: $@'
    @echo ' '

# Other Targets
clean:
    -$(RM) $(LIBRARIES)$(OBJS)$(C_DEPS) mylib.dll
    [email protected] ' '

.PHONY: all clean dependents
.SECONDARY:

-include ../makefile.targets

Conclusion


If you need any further informations, I’d be pleased to provide you what you need.


Download using.my.own.library.implicit.declaration.of.function.zip
Direct Link


Download


Download using.my.own.library.implicit.declaration.of.function.zip
Mediafire


Download


Download using.my.own.library.implicit.declaration.of.function.zip
Uploadstation


Download


Download using.my.own.library.implicit.declaration.of.function.zip
Fileforever


Download


Download using.my.own.library.implicit.declaration.of.function.zip
4Shared


Download