c - How to add default Include and Library path for gcc in Macos for bash? -


this should not difficult task, however, not solve issue hours, posted question here.

the tried links following:
how include needed c library using gcc?
how add default include path gcc in linux?
http://gcc.gnu.org/onlinedocs/gcc-4.8.1/gcc/environment-variables.html#environment-variables
how gcc automatically know include glib library
how compile gcc shared library?
http://www.cprogramming.com/tutorial/shared-libraries-linux-gcc.html

how can add include , lib path cfitsio library gcc compiler?

attempt:

i downloaded , installed cfitsio in path ~/applications. (not /applications btw).
installation commands are:

sudo ./configure   sudo make   sudo make install  

now, let's have program example.c.
compile: gcc -wall -o3 example.c -lm -lcfitsio
not work.

however,

gcc -wall -o3 -o example example.c -i /users/poudel/applications/cfitsio/include  -l /users/poudel/applications/cfitsio/lib -lm -lcfitsio  

works

now don't want use flags -i , -l times. how can so?

i updated ~/.bash_profile following lines:

export path=$path:~/applications/cfitsio/bin export ld_library_path="~/applications/cfitsio:$ld_library_path" export ld_library_path="~/applications/cfitsio/lib:$ld_library_path" export ld_library_path="~/applications/cfitsio/lib/pkgconfig:$ld_library_path" export ld_library_path="~/applications/cfitsio/zlib:$ld_library_path" 

to check paths included after running source ~/.bash_profile used:

echo $ld_library_path 

this shows added paths correctly.

i have added paths not work:

gcc -wall -o3 -o example example.c -lm -lcfitsio

and if give -i , -l flags paths works.

can above command work without using -i , -l commands times?

note:
tried installing cfitsio /usr/local directory.
installed /usr/local/cfitsio again had use -i , -l command these new locations.
frustated this.

the , suggestion appreciated! thanks.

update:

i tried use dyld instead , added these lines in bash_profile:

export path="$(pwd):~/applications/cfitsio/bin:$path" export path="$(pwd):~/applications/cfitsio/include:$path"  # fitsio.h here export dyld_library_path="~/applications/cfitsio/lib:$dyld_library_path" export dyld_library_path="~/applications/cfitsio/zlib:$dyld_library_path" 

however, if run these commands return empty outputs, not set dyld library path these paths.

echo $ld_library_path   echo $dyld_library_path 

following suggestions of jonathan leffler, got way around.
created soft links , worked.

sudo ln -s ~/applications/cfitsio/lib/libcfitsio.a /usr/local/lib/libcfitsio.a  sudo ln -s ~/applications/cfitsio/include/*.h /usr/local/include/ 

in fact, copies header files

~/applications/cfitsio/include    

to

/usr/local/include/   

and worked.

i assume soft links should work.
might simple solution, took hours me figure out.


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -