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

Make build #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Make build #45

wants to merge 1 commit into from

Conversation

Isty001
Copy link

@Isty001 Isty001 commented Aug 14, 2016

A simple build & install task, to create a shared library, so it's not necessary to always include the Parson source, and possible to link against it.

make build sudo make install make clean

and then...

gcc my_source.c -l parson

A simple build & install task, to create a shared library.
@kgabis kgabis self-assigned this Aug 14, 2016
@kgabis
Copy link
Owner

kgabis commented Aug 16, 2016

I cannot merge it right now, because make install doesn't work on macOS. Any idea how to make it work on different operating systems?

@briangorman
Copy link

briangorman commented Jan 31, 2017

Do you have any error messages for Mac OS? Perhaps you can change LIB_DIR=/lib to /usr/lib? This is speculation, I do not have a Mac.

@7heo
Copy link

7heo commented May 30, 2017

/lib is for system libraries, not for general purpose ones. General purpose libraries are supposed to go under /usr/lib. Also, .so files on mac won't work, you need to compile it with gcc -dynamiclib parson.c -o libparson.dylib. So I suggest relying on the travis testing I opened another PR for in order to merge that PR. As a side note, I have another PR in the works for this feature (where I did different rules for the .o and the .so files, and also added some rule for the .a file, in order to provide an object suitable for static linking), so either I will open a PR to correct that one after it is merged, or I will submit my PR directly if my travis PR is merged, and you then can choose what you merge in.

@mbelicki
Copy link

and also added some rule for the .a file

To be honest: what's the point of creating an archive for single object file?

@7heo
Copy link

7heo commented May 30, 2017

@mbelicki

what's the point

7heo commented

in order to provide an object suitable for static linking

I personally do never link against .o objects when they are supposed to be (part of) a library. I always create an .a object: it is easier to link, you do not need the object in the same directory, as you can use -L and -l. And the difference in size is negligible.

@mbelicki
Copy link

Ahhh... you want to install it and link it using -l flag. Then yes, generating archive is a good idea.
Sorry, it should be clear from the context. I probably missed it since for me installing parson seems to be rather inconvenient for normal usage.

@7heo
Copy link

7heo commented May 30, 2017

@mbelicki The use case I would have in mind would be to use the parson repository as a git submodule in your project, and then build the .a in parson from your project's Makefile; and finally use -static -Lparson -lparson from your Makefile at link time.

@mbelicki
Copy link

Then $BIN_DIR/parson.o seems to be far more straight forward than -static -Lparson -lparson.

@7heo
Copy link

7heo commented May 30, 2017

That's a religious opinion. To each their own. Both solutions work, and yours is causing slightly less overhead. Mine is more flexible, as you can install the library on your system as the result of make install, to be used as a static library on all your projects (without the -Lparson in your Makefiles obviously).

@mbelicki
Copy link

It's not a religious opinion. It's a fact. Feeding linker a path to another object just appends an object to collection of objects that linker has to link. The operation you propose involves understanding of three linker flags, which (1) tell it to prefer static linking, (2) add new search directory, (3) search among all potential library location to find one of possible names derived from -lparson. Clearly it is more complex behavior.

This complexity obviously brings the flexibility that you mention.

@7heo
Copy link

7heo commented May 30, 2017

We're not discussing the same thing. I think it's safe to stop the noise here.

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

Successfully merging this pull request may close these issues.

5 participants