1

I want to create a library (Ubuntu, shared or static) from C++ source code. The given source code includes a main() function in "outFile.cpp".

I want to write my own main.cpp file that should be linked to the library like "g++ -lMyLibrary.a" lateron.

Therefore, I want to modify the build script for the C++ source code. What in the build script below do I need to modify in order to generate a library file, excluding any main() function and that provides me all the functions/methods from the source code?

The buildscript uses automake.

buidScript.sh :

#!/bin/bash

./autogen.sh ;
./autogen.sh ;

export CXXFLAGS="-O2"
export CFLAGS="-O2"
export CPPFLAGS="-D__STATIC_LINK -DBUILD_WITH_GPL3rdP -DBUILD_LIBSVM ...."

./configure --prefix=$INSTPREFIX --enable-static --enable-shared=no

./update_build_version.sh

make clean &&
make -j8 ; make install

g++ $CFLAGS -static -o outFile outFile-outFile.o  -lm -pthread .libs/libMyLibrary.a

Makefile.am:

ACLOCAL_AMFLAGS = -I m4

AUTOMAKE_OPTIONS = subdir-objects

bin_PROGRAMS = outFile

...

NEWMAT_SOURCES=\
NEWMAT_CPPFLAGS = -I ../thirdparty

NEWMAT_LDFLAGS = 

LIB_SOURCES=\

lib_LTLIBRARIES = libMyLibrary.la
  libMyLibrary_la_SOURCES = $(MyLibrary_SOURCES)
  libMyLibrary_la_CPPFLAGS = $(MyLibrary_CPPFLAGS)
  libMyLibrary_la_LIBADD = $(MyLibrary_LIBS)
  libMyLibrary_la_LDFLAGS = --no-undefined

Sorry for the weak description, its the first build script I write and I'm still reading about the necessary tools. Thanks.

user3521269
  • 458
  • 3
  • 9

0 Answers0