alljoyn Application build error #error No OS GROUP DEFINED - build

I am trying to build one alljoyn application for openwrt.
I am getting the following error
usr/include/qcc/platform.h:32:2 error: #error No OS GROUP defined.
I am using Makefile to build my application.
I have two makefiles.
My top level Makefile's compile section looks like
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) \
C_INCLUDE_PATH="$(STAGING_DIR)/usr/include" \
CPLUS_INCLUDE_PATH="$(STAGING_DIR)/usr/include" \
CC="$(TARGET_CC)" \
WS=off \
EXTRA_CFLAGS="$(TARGET_CFLAGS) -DQCC_OS_GROUP_POSIX -DQCC_OS_LINUX" \
CROSS_COMPILE="$(TARGET_CROSS)" \
CPPFLAGS="-I$(STAGING_DIR)/usr/include \
-I$(STAGING_DIR)/usr/include/uClibc++ -fno-builtin -fno-rtti \
-nostdinc++ -fpermissive -Wno-error" \
LDFLAGS="$(TARGET_LDFLAGS) -lalljoyn -lcrypt -ldl $(GpioLdflags-y)"
endef
and the makefile inside src directory looks like as follows.
CC := $(CROSS_COMPILE)g++
all : aj-sample
%.o : %.cc
$(CC) -c $(EXTRA_CFLAGS) $(CPPFLAGS) $(INCLUDES) -o $# $<
LIBS := -lalljoyn -luClibc++ -lpthread
aj-sample : aj-sample.o
$(LD) aj-sample.o $(LIBS) $<
clean :
-rm -f *.o
I also tried adding -DQCC_OS_GROUP_POSIX -DQCC_OS_LINUX in src level makefile. But the issue still remains same.
I have already installed the alljoyn from openwrt feeds which compiles successfully.
I appreciate any help.

Related

Problem linking when attempting to include btstack C files (.h & .c) in c++ program

I'm attempting to integrate an L2CAP server (in C - uses BlueKitchen's btstack) with a UDP server (in C++). To start, I've attempted to just add the code from the L2CAP server into the "main.cpp" file of the UDP server. I included all of the relevant C libraries and headers using extern "C" {...}. At first, I'd get errors on the include statements for the btstack files. I solved this by modifying the make file to include "INC = -I./directory/...". Next, I dealt with problems the g++ compiler found with the pasted C code (ex. adding spaces between literals and strings). After resolving those, it seems that none of the bstack files/functions are being linked properly as this is what I get when I attempt to "make":
"undefined reference to 'every single btstack function call in main.cpp'
My makefile. Note that a lot of this is probably unnecessary/does nothing. I was just trying anything and everything and borrowing lines from the btstack port makefile and seeing if they'd work.
CORE += \
btstack_chipset_bcm.c \
btstack_chipset_bcm_download_firmware.c \
btstack_control_raspi.c \
btstack_link_key_db_tlv.c \
btstack_run_loop_posix.c \
btstack_tlv_posix.c \
btstack_uart_posix.c \
btstack_slip.c \
hci_dump_posix_fs.c \
hci_transport_h4.c \
hci_transport_h5.c \
le_device_db_tlv.c \
main.c \
wav_util.c \
btstack_stdin_posix.c \
raspi_get_model.c \
rijndael.c
.INCLUDE : home/pi/udpDemo/inc/btstack-master/example/Makefile.inc
CC=g++
CFLAGS=-Wall -Wextra -pedantic -std=c++11
SRC=$(wildcard ./src/*.cpp)
OBJ=$(patsubst ./src/%.cpp, ./obj/%.o, $(SRC))
INC=-I./inc \
-I./inc/btsrc \
-I./inc/btsrc/ble \
-I./inc/btsrc/ble/gatt-service \
-I./inc/platform/embedded \
-I./inc/platform/posix \
-I./inc/chipset/bcm \
-I./inc/3rd-party/tinydir \
-I./inc/3rd-party/rijndael \
-I./inc/port/raspi \
-I./src
LDFLAGS += -lrt
VPATH += src
VPATH += inc/3rd-party/rijndael
VPATH += inc
VPATH += inc/btsrc \
VPATH += inc/btsrc/ble \
VPATH += inc/btsrc/ble/gatt-service \
VPATH += inc/platform/embedded \
VPATH += inc/platform/posix \
VPATH += inc/chipset/bcm \
VPATH += inc/3rd-party/tinydir \
VPATH += inc/3rd-party/rijndael \
VPATH += inc/port/raspi \
LIBS=
TARGET=test
bindir=/usr/local/bin
$(TARGET):$(OBJ)
$(CC) -o $# $^ $(CFLAGS)
$(OBJ):./obj/%.o:./src/%.cpp
$(CC) $(CFLAGS) -c $^ -o $# -I$(INC)
clean:
rm -rf $(TARGET) $(OBJ)
install:$(TARGET)
install -g root -o root $(TARGET) $(bindir)/$(TARGET)
uninstall:$(bindir)/$(TARGET)
rm $(bindir)/$(TARGET)
It looks like there are both makefile issues and compile issues here. Solving both at the same time is hard. Below is a simplified and commented (but untested) version of your makefile that might be a good starting point for you.
Your original makefile looks like it was including a lot of stuff from the btstack build system. It's usually not a good idea to mesh two separate projects together like that, both for technical and licensing reasons. The typical way to use third-party code is to compile that code into a library and then have your code link against that library. You'll have to consult the documentation for btstack for details on how to do that, I'm not familiar with that particular library.
# Which compiler to use
CC=g++
# Options to pass to the compiler
CFLAGS=-Wall -Wextra -pedantic -std=c++11
# Options to pass to the linker
LDFLAGS=-Wall -Wextra
LDFLAGS+=-lbtstack # Link with 'libbtstack.a'
LDFLAGS+=-L/path/to/btstack # Where to find the btstack libraries that were built separately
# Source files to compile (everything in 'src' directory)
SRC=$(wildcard src/*.cpp)
# Convert names of source files into their corresponding object files
OBJ=$(patsubst src/%.cpp, obj/%.o, $(SRC))
# Directories where headers are kept
INC=-Isrc
INC+=-I/path/to/btstack/headers
# Name of the program
TARGET=test
# Rule for linking the .o files together to build the program
$(TARGET): $(OBJ)
$(CC) $(LDFLAGS) -o $# $^
# Rule for making a .o file from a .cpp file
obj/%.o: src/%.cpp
$(CC) $(CFLAGS) -c $^ -o $# -I$(INC)
# Rule for deleting output and temporary files
clean:
rm -rf $(TARGET) $(OBJ)
This will compile all the .cpp files in your src directory and link them with libbtstack.a to create a program named test. After you build the btstack library, update the LDFLAGS and INC variables with the actual paths to the btstack library and headers, respectively.

C++ Makefile on "complex" tree structure

I have found a lot of related questions, but I was still not able to make my own Makefile.
This makefile is using Mingw64 on Windows, and I want it to run on *nix, currently Debian, but I would like to be able to make it run on Alpine too, as it's used in a Docker container.
The project tree structure is something like :
./
src/
main.cpp
Server.cpp <- use asio and Utils/Split.h
Server.h <- use asio
Utils/
Split.h
lib/
asio/include/ <- asio library (without boost, header only)
Makefile <- That is what I am trying to do right now
Dockerfile
I tried multiple things, here is my latest Makefile (that obviously, does not work) :
NAME := GameServer
CXX := g++
CXXFLAGS := -std=c++2a -DASIO_STANDALONE
SRC_DIR := ./src
LIBS := -I lib/asio-1.18.1/include \
-I lib/rapidjson-1.1.0/include \
-I src
rwildcard = $(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
SRCS := $(call rwildcard,$(SRC_DIR),*.cpp)
OBJS := $(SRCS:%.cpp=%.o)
.PHONY: all
all: $(NAME)
$(NAME): $(OBJS)
$(CXX) -o $# $^
$(OBJS): $(SRCS)
$(CXX) $(CXXFLAGS) -c -o $# $< $(LIBS)
Note: the code (.cpp, .h) is valid, it's coming from an already-running project, but built on Visual Studio (compiled with MSVC).
Here are the two functions done my mingw32-make :
g++ -c -o src/Server.o src/main.cpp -I lib/asio/include -I src
g++ -o Server src/main.o src/Server.o
First line : It should builds the .o from the .cpp and adds the include to asio. I added -I src to add src/Utils, but I guess that's not the way of doing it ?
Second line : It should (link ?) the two .o in a single file : the executable.
The errors I am getting with this makefile are :
src/Server.o:main.cpp:(.text+0x36): multiple definition of 'main', src/main.o:main.cpp:(.text+0x36): first defined here (and this, for every .o)
src/main.o:main.cpp:(.text+0x4b): undefined reference to 'Server::Server()' (and this, for every Server methods main calls, even some from asio)
They appears when the second g++ line starts (g++ -o Server src/main.o src/Server.o)
So here are my questions :
What am I doing wrong ?
Is there a better way of trying to make a development environment on Windows and still be able to copy the project in a Docker container (and then compile it with the gcc image) to build it with the same Makefile ?
Sorry if I forgot to mention some details, I am new with Mingw and its environment.
Thank you
Edit : Corrected version :
NAME := GameServer
CXX := g++
CXXFLAGS := -std=c++1z
SRC_DIR := ./src
LIBS := -lwsock32 -lws2_32 \
-I lib/asio-1.18.1/include \
-I lib/rapidjson-1.1.0/include \
-I src
rwildcard = $(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
SRCS := $(call rwildcard,$(SRC_DIR),*.cpp)
OBJS := $(SRCS:%.cpp=%.o)
.PHONY: all
all: $(NAME)
$(NAME): $(OBJS)
$(CXX) -o $# $^ $(LIBS)
$(OBJS): $(SRC_DIR)/%.o: $(SRC_DIR)/%.cpp
$(CXX) $(CXXFLAGS) -c -o $# $< $(LIBS)
Consider the rule...
$(OBJS): $(SRCS)
$(CXX) $(CXXFLAGS) -c -o $# $< $(LIBS)
This tells make that all items in $(OBJS) depend on all items in $(SRCS). But the command...
$(CXX) $(CXXFLAGS) -c -o $# $< $(LIBS)
...always compiles the first dependency as identified by $<. It just so happens that in your case $< is src/main.cpp.
Instead you should probably use a pattern rule such as...
$(SRC_DIR)/%.o: $(SRC_DIR)/%.cpp
$(CXX) $(CXXFLAGS) -c -o $# $< $(LIBS)
You can also limit the scope of that rule to only those targets specified by $(OBJS) with a full static pattern rule...
$(OBJS): $(SRC_DIR)/%.o: $(SRC_DIR)/%.cpp
$(CXX) $(CXXFLAGS) -c -o $# $< $(LIBS)

How do I expend this Makefile to use wildcards?

I would like to adopt the following Makefile from this tutorial to more generic targets. For example, if I type make foo, then I expect an executable foo to be built from foo.v and foo.cpp in a process similar to that of making maskbus.
.PHONY: all
all: maskbus
obj_dir/Vmaskbus.cpp: maskbus.v
verilator -Wall -cc maskbus.v
obj_dir/Vmaskbus__ALL.a: obj_dir/Vmaskbus.cpp
make -C obj_dir -f Vmaskbus.mk
maskbus: maskbus.cpp obj_dir/Vmaskbus__ALL.a
g++ -I/usr/share/verilator/include -I obj_dir \
/usr/share/verilator/include/verilated.cpp \
maskbus.cpp obj_dir/Vmaskbus__ALL.a \
-o maskbus
.PHONY: clean
clean:
rm -rf obj_dir/ maskbus
Here is what I have tried
.PHONY: all
stuff: $(basename $(wildcard *.v))
all: stuff
obj_dir/%.cpp: %.v
verilator -Wall -cc $<
obj_dir/V%__ALL.a: obj_dir/V%.cpp
make -C obj_dir -f Vmaskbus.mk
stuff: $#.cpp obj_dir/V$#__ALL.a
g++ -I/usr/share/verilator/include -I obj_dir \
/usr/share/verilator/include/verilated.cpp \
$#.cpp obj_dir/V$#__ALL.a \
-o $#
.PHONY: clean
clean:
rm -rf obj_dir/ $(stuff)
Nota that I left the name Vmaskbus unchanged in the second rule as I have no idea how to extract the correct "basename" from a rule containing %. However, when I run make foo, that rule isn't even executed, and thus subsequent commands fail due to the absence of obj_dir/Vfoo__ALL.a. Some investigation suggests that the variable stuff is empty, but I'm sure I have both foo.v and foo.cpp in the current directory.
Figured it out myself:
.PHONY: all clean
stuff := $(basename $(wildcard *.v))
all: $(stuff)
obj_dir/V%.cpp: %.v
verilator -Wall -cc $<
obj_dir/V%__ALL.a: obj_dir/V%.cpp
make -C obj_dir -f V$*.mk
$(stuff): %: %.cpp obj_dir/V%__ALL.a
g++ -I /opt/local/share/verilator/include \
-I obj_dir \
-o $# \
/opt/local/share/verilator/include/verilated.cpp \
obj_dir/V$*__ALL.a \
$*.cpp
clean:
rm -rf obj_dir/ $(stuff)

Makefile for cross compilation linux

I have been asked to port our product into another application.(our s/w is running on linux virtualbox)
I have got a directory of their interface files and also a example code on trying to configure their software/hardware. I see their interface files under the s/w directory. In the reference code directory, I see a makefile with the reference to their reference code.
Trying to run their reference code makefile. getting error that
make: *** No rule to make target `../ main.o" :(
Btw donot understand why SIMUDIR = -I\..\custom_simcode\ this is done in the makefile ?
Also not much familiar with crosscompiler syntax !
ifndef CROSS_CC_PREFIX
CROSS_CC_PREFIX=$(CROSS_COMPILE)
endif
PROGRAM = customer_sim
CC=$(CROSS_CC_PREFIX)gcc
LD=$(CROSS_CC_PREFIX)ld
RANLIB=$(CROSS_CC_PREFIX)corelib
CFLAGS= -g
all: $(PROGRAM)
## Include path
SIMUDIR = -I\..\custom_simcode\
CUST_INT_INC = -I./../cust_Intf/DecHandler/inc \
-I./../CCPU
LIBDIR = -L./../cust_Intf \
-L./../cust_IntfApi
LIBS = -lpthread -customercif -customerapi
LDFLAGS= $(LIBDIR) $(LIBS)
SOURCE = ./../custom_simcode/main.c \
./../custom_simcode/custcode_primitives_init.c \
./../custom_simcode/custccp_primitives_init.c
CFLAGS += $(SIMUDIR) $(CUST_INT_INC) -DPRINT_IO_CONSOLE -UADAPT_CCPU_CUSTIF
OBJS = $(SOURCE:.c=.o)
$(PROGRAM): $(OBJS)
$(CC) -o $# $(OBJS) $(LDFLAGS)
main.o: $(SIMUDIR)/main.c $(SIMUDIR) $(CUST_INT_INC)
$(CC) -c -o /main.o $(SIMUDIR)/main.c
clean:
-rm -f $(OBJS) $(OBJS) $(PROGRAM)
Your $(OBJS) list dependencies for $(PROGRAMs) with directories included but your rule for main.o doesn't have same path.
It would be better to have a generic rule to compile C files like
%.o: %.c
$(CC) -c -o $# $<
Then simply assign extra dependencies for each file like:
$(OBJS): $(SIMUDIR) $(CUST_INT_INC)

Building library with static lib and c++ sourse code

I have a static library (lwip) compiled with this makefile:
CCDEP=g++
CC=g++
#To compile for linux: make ARCH=linux
#To compile for cygwin: make ARCH=cygwin
ARCH=unix
CFLAGS=-g -Wall -D$(ARCH) -DIPv4 -DLWIP_DEBUG -fpermissive \
-Wparentheses -Wsequence-point -Wswitch-default \
-Wextra -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast \
-Wc++-compat -Wwrite-strings -Wold-style-definition \
-Wmissing-prototypes -Wredundant-decls -Wnested-externs
# not used for now but interesting:
# -Wpacked
# -Wunreachable-code
# -ansi
# -std=c89
LDFLAGS=-lpthread -lutil -lboost_thread
CONTRIBDIR=../../../..
LWIPARCH=$(CONTRIBDIR)/ports/unix
ARFLAGS=rs
#Set this to where you have the lwip core module checked out from CVS
#default assumes it's a dir named lwip at the same level as the contrib module
LWIPDIR=$(CONTRIBDIR)/../lwip/src
CFLAGS:=$(CFLAGS) \
-I. -I$(CONTRIBDIR)/apps/httpserver_raw -I$(CONTRIBDIR)/apps/shell \
-I$(CONTRIBDIR)/apps/tcpecho -I$(CONTRIBDIR)/apps/udpecho \
-I$(LWIPDIR)/include -I$(LWIPARCH)/include -I$(LWIPDIR)/include/ipv4 \
-I$(LWIPDIR) -I$(CONTRIBDIR)
# -I$(CLASSDIR)/inc
# COREFILES, CORE4FILES: The minimum set of files needed for lwIP.
COREFILES=$(LWIPDIR)/core/mem.c $(LWIPDIR)/core/memp.c $(LWIPDIR)/core/netif.c \
$(LWIPDIR)/core/pbuf.c $(LWIPDIR)/core/raw.c $(LWIPDIR)/core/stats.c \
$(LWIPDIR)/core/sys.c $(LWIPDIR)/core/tcp.c $(LWIPDIR)/core/tcp_in.c \
$(LWIPDIR)/core/tcp_out.c $(LWIPDIR)/core/udp.c $(LWIPDIR)/core/dhcp.c \
$(LWIPDIR)/core/init.c $(LWIPDIR)/core/timers.c $(LWIPDIR)/core/def.c \
CORE4FILES=$(wildcard $(LWIPDIR)/core/ipv4/*.c) $(LWIPDIR)/core/ipv4/inet.c \
$(LWIPDIR)/core/ipv4/inet_chksum.c
# SNMPFILES: Extra SNMPv1 agent
SNMPFILES=$(LWIPDIR)/core/snmp/asn1_dec.c $(LWIPDIR)/core/snmp/asn1_enc.c \
$(LWIPDIR)/core/snmp/mib2.c $(LWIPDIR)/core/snmp/mib_structs.c \
$(LWIPDIR)/core/snmp/msg_in.c $(LWIPDIR)/core/snmp/msg_out.c
# APIFILES: The files which implement the sequential and socket APIs.
APIFILES=$(LWIPDIR)/api/api_lib.c $(LWIPDIR)/api/api_msg.c $(LWIPDIR)/api/tcpip.c \
$(LWIPDIR)/api/err.c $(LWIPDIR)/api/sockets.c $(LWIPDIR)/api/netbuf.c \
$(LWIPDIR)/api/netdb.c
# NETIFFILES: Files implementing various generic network interface functions.'
NETIFFILES=$(LWIPDIR)/netif/etharp.c $(LWIPDIR)/netif/slipif.c
# NETIFFILES: Add PPP netif
NETIFFILES+=$(LWIPDIR)/netif/ppp/auth.c $(LWIPDIR)/netif/ppp/chap.c \
$(LWIPDIR)/netif/ppp/chpms.c $(LWIPDIR)/netif/ppp/fsm.c \
$(LWIPDIR)/netif/ppp/ipcp.c $(LWIPDIR)/netif/ppp/lcp.c \
$(LWIPDIR)/netif/ppp/magic.c $(LWIPDIR)/netif/ppp/md5.c \
$(LWIPDIR)/netif/ppp/pap.c $(LWIPDIR)/netif/ppp/ppp.c \
$(LWIPDIR)/netif/ppp/randm.c $(LWIPDIR)/netif/ppp/vj.c \
$(LWIPARCH)/netif/sio.c
# ARCHFILES: Architecture specific files.
ARCHFILES=$(wildcard $(LWIPARCH)/*.c $(LWIPARCH)/netif/tapif.c $(LWIPARCH)/netif/tunif.c
$(LWIPARCH)/netif/unixif.c $(LWIPARCH)/netif/list.c $(LWIPARCH)/netif/tcpdump.c)
# APPFILES: Applications.
APPFILES=$(CONTRIBDIR)/apps/httpserver_raw/fs.c
$(CONTRIBDIR)/apps/httpserver_raw/httpd.c \
$(CONTRIBDIR)/apps/udpecho/udpecho.c $(CONTRIBDIR)/apps/tcpecho/tcpecho.c \
$(CONTRIBDIR)/apps/shell/shell.c
# LWIPFILES: All the above.
LWIPFILES=$(COREFILES) $(CORE4FILES) $(SNMPFILES) $(APIFILES) $(NETIFFILES) $(ARCHFILES)
LWIPFILESW=$(wildcard $(LWIPFILES))
LWIPOBJS=$(notdir $(LWIPFILESW:.c=.o))
#LWIPOBJS+=$(notdir $(LWIPFILESW:.cpp=.o))
LWIPLIB=liblwip4.a
APPLIB=liblwipapps.a
APPOBJS=$(notdir $(APPFILES:.c=.o))
#APPOBJS+=$(notdir $(APPFILES:.cpp=.o))
%.o:
$(CC) $(CFLAGS) -c $(<:.o=.c)
all ipv4 compile: liblwip4.a
#all ipv4 compile: simhost
.PHONY: all
clean:
rm -f *.o $(LWIPLIB) $(APPLIB) simhost simnode simrouter *.s .depend* *.core core
depend dep: .depend
include .depend
$(APPLIB): $(APPOBJS)
$(AR) $(ARFLAGS) $(APPLIB) $?
$(LWIPLIB): $(LWIPOBJS)
$(AR) $(ARFLAGS) $(LWIPLIB) $?
.depend: simhost.c simnode.c simrouter.c $(LWIPFILES) $(APPFILES)
$(CCDEP) $(CFLAGS) -MM $^ > .depend || rm -f .depend
simhost: .depend $(LWIPLIB) $(APPLIB) simhost.o $(APPFILES)
$(CC) $(CFLAGS) $(LDFLAGS) -o simhost simhost.o $(APPLIB) $(LWIPLIB)
simrouter: .depend $(LWIPLIB) $(APPLIB) simrouter.o
$(CC) $(CFLAGS) $(LDFLAGS) -o simrouter simrouter.o $(APPLIB) $(LWIPLIB)
simnode: .depend $(LWIPLIB) $(APPLIB) simnode.o
$(CC) $(CFLAGS) $(LDFLAGS) -o simnode simnode.o $(APPLIB) $(LWIPLIB)
Many of these things are not needed - that was example of application in 'contrib' folder. So... I get liblwip4.a library - for now all fine.
With this Library I made some test application - a class that uses lwip lib for different connections. I used eclipse IDE (added all includes, the liblwip4.a and so on) and it works fine.
Now I want to make a my_lwiplib.a or my_lwiplib.so with this lwip lib and my class. I made directory with 3 folders - lwip(sourse files), contrib-1.4.1(platform dependent files and so on) and lwipClass(my .h and .cpp file). wrote makefile:
CC = g++
CFLAGS = -fPIC -g -fpermissive
LDFLAGS = -shared
READYLIB = ./contrib-1.4.1/ports/unix/proj/unixsim/liblwip4.a
SOURCES = $(wildcard lwipClass/src/*.cpp)
INCLUDES = -I./lwipClass/inc/ -I./lwip/src/include/ -I./lwip/src/include/lwip/
OBJECTS = $(SOURCES:.cpp=.o)
CFLAGS += $(INCLUDES)
TARGET_SO = libmy_lwip.so
TARGET_STATIC = libmy_lwip.a
clean:
rm -f $(OBJECTS) $(TARGET_SO) $(TARGET_STATIC)
shared : $(OBJECTS)
$(CC) $(CFLAGS) $(OBJECTS) $(READYLIB) -o $(TARGET_SO) $(LDFLAGS)
static : $(OBJECTS)
ar rcs $(TARGET_STATIC) $(OBJECTS) $(READYLIB)
When I do 'make shared' I get:
sudo make shared
g++ -fPIC -g -fpermissive -I./lwipClass/inc/ -I./lwip/src/include/ -
I./lwip/src/include/lwip/ lwipClass/src/lwipClass.o ./contrib-
1.4.1/ports/unix/proj/unixsim/liblwip4.a -o libmy_lwip.so -shared
/usr/bin/ld: lwipClass/src/lwipClass.o: relocation R_X86_64_32 against `.bss' can not be
used when making a shared object; recompile with -fPIC
lwipClass/src/lwipClass.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make: *** [shared] Error 1
What's wrong here?
ADDED 14.08
Tryed to compile static lib. It compils ok.
Linked it to eclipse test project and made test application.
classA *myClass;
myClass->getInstance();
When i Try co compile I get
make all
Building file: ../src/test.cpp
Invoking: GCC C++ Compiler
g++ -fpermissive -I/home/user/lwip/lwipClass/inc -O0 -g3 -Wall -c -fmessage-length=0 -
MMD -MP -MF"src/test.d" -MT"src/test.d" -o "src/test.o" "../src/test.cpp"
Finished building: ../src/test.cpp
Building target: test
Invoking: GCC C++ Linker
g++ -o "test" ./src/test.o /home/user/lwip/libmy_lwip.a -lpthread -lboost_thread
/home/user/lwip/libmy_lwip.a(lwipClass.o): In function
`lwipImpl::tcpecho_thread(void*)':
lwipClass.cpp:(.text+0x85): undefined reference to `netbuf_data'
lwipClass.cpp:(.text+0xb9): undefined reference to `netbuf_next'
lwipClass.cpp:(.text+0xce): undefined reference to `netbuf_delete'
lwipClass.cpp:(.text+0xef): undefined reference to `netconn_recv'
That means there are no such functions.
I do
user:~/lwip$ objdump -t (some way /)/liblwip4.a |grep netbuf_data
00000000000003df g F .text 0000000000000103 netbuf_data
Than I do
usr:~/lwip$ objdump -t (some way/)lwip/libmy_lwip.a |grep netbuf_data
0000000000000000 *UND* 0000000000000000 netbuf_data
objdump: liblwip4.a: File format not recognized
wtf?????
In order to construct a shared library, you must first compile the source code and produce position-independent object files. That's what the -fPIC flag is for. You can't build a shared library out of "ordinary" object files, and you can't change that property of an object file later-- at least not easily.
In your example, you are trying to construct a shared library out of position-dependent object files, via a static library (). You can construct a static library from these objects, but if you want to build a shared library, as the linker is telling you, you must recompile with -fPIC.