如何将makefile从使可执行文件更改为共享库

时间:2014-04-10 16:50:18

标签: c++ shell makefile gnu-make

我有一个开源库,当我运行构建脚本(.sh)时,它会创建一个可执行文件。

我需要将库函数包含在另一个项目中,所以我想创建一个.so文件(我在Ubuntu上运行它)。

makefile中的定义是什么?为了获取mylib.so文件,我将如何调整它?

Makefile:

    # ACLOCAL_AMFLAGS = -I m4

AUTOMAKE_OPTIONS = subdir-objects

bin_PROGRAMS = mybin 

MYLIB_SOURCES=\
    src/functions.cpp \

  MYLIB_SOURCES=$(MYLIB_SOURCES)

  MYLIB_CPPFLAGS = -Isrc/include -ggdb $(PTHREAD_CFLAGS)
  MYLIB_LIBS =  $(PTHREAD_LIBS) $(DLIB)

  MYLIB_SOURCES = progsrc/mybin/mybin.cpp 
  MYLIB_CPPFLAGS = $(MYBIN_CPPFLAGS)
  MYLIB_LDADD = $(MYBIN_LIBS) -lmybin

  lib_LTLIBRARIES = mybin.la
  libmybin_la_SOURCES = $(MYBIN_SOURCES)
  libmybin_la_CPPFLAGS = $(MYBIN_CPPFLAGS)
  libmybin_la_LIBADD = $(MYBIN_LIBS)
  libmybin_la_LDFLAGS = --no-undefined

# endif 

感谢。

1 个答案:

答案 0 :(得分:2)

只需删除此行:

bin_PROGRAMS = mybin