jgm / peg-markdown

An implementation of markdown in C, using a PEG grammar
Other
696 stars 140 forks source link

Undefined references when using as shared library #29

Open ghost opened 11 years ago

ghost commented 11 years ago

Hey there, I'm trying to use peg-markdown as a shared library built by this Makefile:

CC=clang
CFLAGS=-c -g -Wall

all: clog
    $(CC) obj/main.o -Llibs/peg-markdown -lpeg-markdown -o clog

clog: src/main.c peg-markdown
    $(CC) $(CFLAGS) src/main.c `pkg-config --cflags glib-2.0` -o obj/main.o

peg-markdown:
    make CC="gcc -fPIC" -C libs/peg-markdown/ library

The generation of the .so seems to work fine but when I try to compile my main program, clang just tells me it does not know how to deal with the gstring stuff:

clang obj/main.o -Llibs/peg-markdown -lpeg-markdown -o clog
libs/peg-markdown/libpeg-markdown.so: error: undefined reference to 'g_string_new'
libs/peg-markdown/libpeg-markdown.so: error: undefined reference to 'g_slist_free'
libs/peg-markdown/libpeg-markdown.so: error: undefined reference to 'g_slist_reverse'
libs/peg-markdown/libpeg-markdown.so: error: undefined reference to 'g_string_free'
libs/peg-markdown/libpeg-markdown.so: error: undefined reference to 'g_slist_prepend'
libs/peg-markdown/libpeg-markdown.so: error: undefined reference to 'g_string_append_printf'
libs/peg-markdown/libpeg-markdown.so: error: undefined reference to 'g_string_append'
libs/peg-markdown/libpeg-markdown.so: error: undefined reference to 'g_string_insert_c'

I tried using clang 3.3 and gcc 4.8.1

jgm commented 11 years ago

I don't know. You might write to the person who contributed the patch for building a shared library. (Look at the commit logs.)

+++ Lars Herbach [Sep 03 13 10:36 ]:

Hey there, I'm trying to use peg-markdown as a shared library built by this Makefile: CC=clang CFLAGS=-c -g -Wall

all: clog $(CC) obj/main.o -Llibs/peg-markdown -lpeg-markdown -o clog

clog: src/main.c peg-markdown $(CC) $(CFLAGS) src/main.c pkg-config --cflags glib-2.0 -o obj/main.o

peg-markdown: make CC="gcc -fPIC" -C libs/peg-markdown/ library

The generation of the .so seems to work fine but when I try to compile my main program, clang just tells me it does not know how to deal with the gstring stuff: clang obj/main.o -Llibs/peg-markdown -lpeg-markdown -o clog libs/peg-markdown/libpeg-markdown.so: error: undefined reference to 'g_string_ne w' libs/peg-markdown/libpeg-markdown.so: error: undefined reference to 'g_slist_fre e' libs/peg-markdown/libpeg-markdown.so: error: undefined reference to 'g_slist_rev erse' libs/peg-markdown/libpeg-markdown.so: error: undefined reference to 'g_string_fr ee' libs/peg-markdown/libpeg-markdown.so: error: undefined reference to 'g_slist_pre pend' libs/peg-markdown/libpeg-markdown.so: error: undefined reference to 'g_string_ap pend_printf' libs/peg-markdown/libpeg-markdown.so: error: undefined reference to 'g_string_ap pend' libs/peg-markdown/libpeg-markdown.so: error: undefined reference to 'g_string_in sert_c'

I tried using clang 3.3 and gcc 4.8.1

— Reply to this email directly or [1]view it on GitHub. [xJAuenYDiIoVt3LF3y68412lOGlbZ7PtIvCEmk88aveh2oQ2RUgC7Q_xLPVykXJS.gif]

References

  1. https://github.com/jgm/peg-markdown/issues/29
yanlinlin82 commented 11 years ago

You might have to add pkg-config --libs glib-2.0 to your compiling rule of 'clog' to link the glib.

On Wed, Sep 4, 2013 at 1:36 AM, Lars Herbach notifications@github.comwrote:

Hey there, I'm trying to use peg-markdown as a shared library built by this Makefile:

CC=clang CFLAGS=-c -g -Wall

all: clog $(CC) obj/main.o -Llibs/peg-markdown -lpeg-markdown -o clog

clog: src/main.c peg-markdown $(CC) $(CFLAGS) src/main.c pkg-config --cflags glib-2.0 -o obj/main.o

peg-markdown: make CC="gcc -fPIC" -C libs/peg-markdown/ library

The generation of the .so seems to work fine but when I try to compile my main program, clang just tells me it does not know how to deal with the gstring stuff:

clang obj/main.o -Llibs/peg-markdown -lpeg-markdown -o clog libs/peg-markdown/libpeg-markdown.so: error: undefined reference to 'g_string_new' libs/peg-markdown/libpeg-markdown.so: error: undefined reference to 'g_slist_free' libs/peg-markdown/libpeg-markdown.so: error: undefined reference to 'g_slist_reverse' libs/peg-markdown/libpeg-markdown.so: error: undefined reference to 'g_string_free' libs/peg-markdown/libpeg-markdown.so: error: undefined reference to 'g_slist_prepend' libs/peg-markdown/libpeg-markdown.so: error: undefined reference to 'g_string_append_printf' libs/peg-markdown/libpeg-markdown.so: error: undefined reference to 'g_string_append' libs/peg-markdown/libpeg-markdown.so: error: undefined reference to 'g_string_insert_c'

I tried using clang 3.3 and gcc 4.8.1

— Reply to this email directly or view it on GitHubhttps://github.com/jgm/peg-markdown/issues/29 .

ghost commented 11 years ago

pkg-config --libs glib-2.0 did not change anything.

On 09/03/13 23:33, yanlinlin82 wrote:

You might have to add pkg-config --libs glib-2.0 to your compiling rule of 'clog' to link the glib.

On Wed, Sep 4, 2013 at 1:36 AM, Lars Herbach notifications@github.comwrote:

Hey there, I'm trying to use peg-markdown as a shared library built by this Makefile:

CC=clang CFLAGS=-c -g -Wall

all: clog $(CC) obj/main.o -Llibs/peg-markdown -lpeg-markdown -o clog

clog: src/main.c peg-markdown $(CC) $(CFLAGS) src/main.c pkg-config --cflags glib-2.0 -o obj/main.o

peg-markdown: make CC="gcc -fPIC" -C libs/peg-markdown/ library

The generation of the .so seems to work fine but when I try to compile my main program, clang just tells me it does not know how to deal with the gstring stuff:

clang obj/main.o -Llibs/peg-markdown -lpeg-markdown -o clog libs/peg-markdown/libpeg-markdown.so: error: undefined reference to 'g_string_new' libs/peg-markdown/libpeg-markdown.so: error: undefined reference to 'g_slist_free' libs/peg-markdown/libpeg-markdown.so: error: undefined reference to 'g_slist_reverse' libs/peg-markdown/libpeg-markdown.so: error: undefined reference to 'g_string_free' libs/peg-markdown/libpeg-markdown.so: error: undefined reference to 'g_slist_prepend' libs/peg-markdown/libpeg-markdown.so: error: undefined reference to 'g_string_append_printf' libs/peg-markdown/libpeg-markdown.so: error: undefined reference to 'g_string_append' libs/peg-markdown/libpeg-markdown.so: error: undefined reference to 'g_string_insert_c'

I tried using clang 3.3 and gcc 4.8.1

— Reply to this email directly or view it on GitHubhttps://github.com/jgm/peg-markdown/issues/29 .

— Reply to this email directly or view it on GitHub https://github.com/jgm/peg-markdown/issues/29#issuecomment-23748794.