Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined references when using as shared library #29

Open
ghost opened this issue Sep 3, 2013 · 3 comments
Open

Undefined references when using as shared library #29

ghost opened this issue Sep 3, 2013 · 3 comments

Comments

@ghost
Copy link

ghost commented Sep 3, 2013

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
Copy link
Owner

jgm commented Sep 3, 2013

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. Undefined references when using as shared library #29

@yanlinlin82
Copy link

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 [email protected]:

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//issues/29
.

@ghost
Copy link
Author

ghost commented Sep 4, 2013

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
[email protected]:

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//issues/29
.


Reply to this email directly or view it on GitHub
#29 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants