When I compile a .cpp file I get the errors as in the picture. I have installed fftw3(via cygwin setup.exe) and fftw2 (manually). I am able to find fftw3.h and rfftw.h when I search for them. What am I missing?
Errors as displayed in cygwin:
.
Look at the development package content:
$ cygcheck -l libfftw3-devel
/usr/include/fftw3.f
/usr/include/fftw3.f03
/usr/include/fftw3.h
/usr/include/fftw3l.f03
/usr/include/fftw3q.f03
/usr/lib/libfftw3.dll.a
/usr/lib/libfftw3f.dll.a
/usr/lib/libfftw3f_omp.dll.a
/usr/lib/libfftw3f_threads.dll.a
/usr/lib/libfftw3l.dll.a
/usr/lib/libfftw3l_omp.dll.a
/usr/lib/libfftw3l_threads.dll.a
/usr/lib/libfftw3_omp.dll.a
/usr/lib/libfftw3_threads.dll.a
/usr/lib/pkgconfig/fftw3.pc
/usr/lib/pkgconfig/fftw3f.pc
/usr/lib/pkgconfig/fftw3l.pc
so the import library is /usr/lib/libfftw3.dll.a
and need -lfttw3. Same info from pkg-config
$ pkg-config --libs fftw3
-lfftw3
Related
Here is an example how to specify PATHS variable to make cmake be able to find library:
cmake find_package specify path
But how to get this PATHS variable for specific library?
For example I have installed apt-get install libharfbuzz-dev and dpkg -L libharfbuzz-dev shows me:
/usr
/usr/include
/usr/include/harfbuzz
/usr/include/harfbuzz/hb-blob.h
/usr/include/harfbuzz/hb-buffer.h
/usr/include/harfbuzz/hb-common.h
/usr/include/harfbuzz/hb-deprecated.h
/usr/include/harfbuzz/hb-face.h
/usr/include/harfbuzz/hb-font.h
/usr/include/harfbuzz/hb-ft.h
/usr/include/harfbuzz/hb-glib.h
/usr/include/harfbuzz/hb-gobject-enums.h
/usr/include/harfbuzz/hb-gobject-structs.h
/usr/include/harfbuzz/hb-gobject.h
/usr/include/harfbuzz/hb-graphite2.h
/usr/include/harfbuzz/hb-icu.h
/usr/include/harfbuzz/hb-ot-font.h
/usr/include/harfbuzz/hb-ot-layout.h
/usr/include/harfbuzz/hb-ot-math.h
/usr/include/harfbuzz/hb-ot-shape.h
/usr/include/harfbuzz/hb-ot-tag.h
/usr/include/harfbuzz/hb-ot-var.h
/usr/include/harfbuzz/hb-ot.h
/usr/include/harfbuzz/hb-set.h
/usr/include/harfbuzz/hb-shape-plan.h
/usr/include/harfbuzz/hb-shape.h
/usr/include/harfbuzz/hb-unicode.h
/usr/include/harfbuzz/hb-version.h
/usr/include/harfbuzz/hb.h
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libharfbuzz-gobject.a
/usr/lib/x86_64-linux-gnu/libharfbuzz-icu.a
/usr/lib/x86_64-linux-gnu/libharfbuzz.a
/usr/lib/x86_64-linux-gnu/pkgconfig
/usr/lib/x86_64-linux-gnu/pkgconfig/harfbuzz-gobject.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/harfbuzz-icu.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/harfbuzz.pc
/usr/share
/usr/share/doc
/usr/share/doc/libharfbuzz-dev
/usr/share/doc/libharfbuzz-dev/copyright
/usr/share/gir-1.0
/usr/share/gir-1.0/HarfBuzz-0.0.gir
/usr/lib/x86_64-linux-gnu/libharfbuzz-gobject.so
/usr/lib/x86_64-linux-gnu/libharfbuzz-icu.so
/usr/lib/x86_64-linux-gnu/libharfbuzz.so
/usr/share/doc/libharfbuzz-dev/changelog.Debian.gz
Which path should I use?
Update:
Error message:
CMake Error at <some_path>/CMakeLists.txt:6 (find_package):
By not providing "FindHarfbuzz.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Harfbuzz",
but CMake did not find one.
Could not find a package configuration file provided by "Harfbuzz" with any
of the following names:
HarfbuzzConfig.cmake
harfbuzz-config.cmake
Add the installation prefix of "Harfbuzz" to CMAKE_PREFIX_PATH or set
"Harfbuzz_DIR" to a directory containing one of the above files. If
"Harfbuzz" provides a separate development package or SDK, be sure it has
been installed.
I tried to add path via CMAKE_PREFIX_PATH like cmake .. -DCMAKE_PREFIX_PATH=/usr/lib/x86_64-linux-gnu but it doesn't help.
yes this question has been asked before. no the other answers doesn't solve my problem.
I have just built isl from source both 0.15 and 0.22.
I have isl and I know where it is and I am amazed that even though I have pointed to where the program is in configure binutils can't find it.
It did work a few months ago to do it this way.
../gitrepos/binutils/configure --prefix=/tools --with-sysroot=x86_64-w64-cygwin --with-lib-path=/tools/lib --disable-nls --disable-werror lt_cv_objdir=.libs --target=x86_64-w64-cygwin --with-isl=/home/brazg/usr/isl/0.22
I am getting the following error: required isl version is 0.15 or
later configure: error: Unable to find a usable isl. See config.log
for details.
/tmp/cc3B0zAy.s: Assembler messages:
/tmp/cc3B0zAy.s:14: Error: unknown .loc sub-directive `view'
/tmp/cc3B0zAy.s:14: Error: junk at end of line, first unrecognized character is `-'
/tmp/cc3B0zAy.s:20: Error: unknown .loc sub-directive `view'
/tmp/cc3B0zAy.s:20: Error: unknown pseudo-op: `.lvu1'
/tmp/cc3B0zAy.s:23: Error: unknown .loc sub-directive `view'
/tmp/cc3B0zAy.s:23: Error: unknown pseudo-op: `.lvu2'
configure:5079: $? = 1
configure: failed program was:
Yes I am aware that there are a whole lot of assembler errors because of the version of GCC in Cygwin. I am trying to replace it by building a more current version of gcc.
This is a common problem I have been running into. when building some source code in Cygwin. It seems one of the programs that runs into this is binutils...
I'm not sure what to do.
and yes, I could try cross compiling in Linux, no I don't want to and I'm hoping I don't have to. I'd like to do this naively to Windows if I can.
It seems to me that you are complicating yourself the life (x86_64-pc-cygwin is platform specific, not your choice) and you should start using the standard cygport tool, the same configuration already used for the binutils cygwin package and the isl 0.16.1 available. When you have problem with configure the proper config.log will provide the hint on what is going wrong.
Herebelow the a recipe to build the last released binutils 2.33.1 and create a cygwin package. For my test I am using the stable packages:
$ cygcheck -cd binutils gcc-core libisl-devel
Cygwin Package Information
Package Version
binutils 2.31.1-1
gcc-core 7.4.0-1
libisl-devel 0.16.1-1
but you can also try with the test 8.3.0-1 gcc compiler.
Download the source package and extract the binutils.cygport
$ wget http://mirrors.kernel.org/sourceware/cygwin/x86/release/binutils/binutils-2.31.1-1-src.tar.xz
$ tar -xf binutils-2.31.1-1-src.tar.xz
$ cp binutils-2.31.1-1.src/binutils.cygport .
Adjusting the cygport file to build from release 2.33.1 and not from git
$ cat binutils.cygport
TOOLCHAIN_TARGET="native"
# GIT_URI="git://sourceware.org/git/binutils-gdb.git"
# inherit toolchain git
# GIT_REV=be46fa23042ec88a7a42030476a301bf72a80e7e
# SRC_DIR=binutils-gdb
NAME="binutils"
VERSION=2.33.1
RELEASE=1
CATEGORY="Devel"
SUMMARY="GNU assembler, linker, and similar utilities"
DESCRIPTION="This directory contains various GNU compilers, assemblers, linkers,
debuggers, etc., plus their support routines, definitions, and documentation."
HOMEPAGE="http://www.gnu.org/software/binutils/"
case ${VERSION} in
*.*.[5-9][0-9])
SRC_URI="ftp://sourceware.org/pub/binutils/snapshots/binutils-${VERSION}.tar.bz2" ;;
*) SRC_URI="mirror://gnu/binutils/binutils-${VERSION}.tar.xz"
SRC_DIR=${PN}-${PV}
;;
esac
#PATCH_URI+=" 2.24.51-shared-libs.patch"
#2.24.51-ld-__dso_handle.patch
#PATCH_URI+="
#2.24.51-ld-__dso_handle.patch
#detect-rebasing-and-compute-an-address-bias.patch
#"
#PATCH_URI="e643cb45bf85fa5c8c49a89ff177de246af4212e.patch"
# gdb,etc.: https://sourceware.org/ml/binutils/2014-01/msg00341.html
# for shared libbfd/libopcodes, add:
# --enable-shared
CYGCONF_ARGS="
--enable-install-libiberty
--disable-gdb
--disable-libdecnumber
--disable-readline
--disable-sim
--enable-64-bit-bfd
"
# --enable-targets=i686-efi-pe,x86_64-efi-pe,ia64-efi-elf,x86_64-pc-cygwin,i686-pc-cygwin
src_install() {
cd ${B}
cyginstall
# for shared libbfd/libopcodes, add:
# APIs are unstable, do not allow linking against DLLs
# rm -f ${D}/usr/lib/*.dll.a
# sed -i -e '/^library_names=/d' ${D}/usr/lib/lib*.la
}
As you can note that I have NOT changed the arguments of binutils configuration. So now I can build the 2.33.1 package:
$ cygport binutils.cygport download
...
binutils-2.33.1.tar 100%[===================>] 20.50M 1.50MB/s in 15s
2020-01-04 17:07:52 (1.38 MB/s) - ‘binutils-2.33.1.tar.xz.tmp’ saved [21490848/21490848]
$ cygport binutils.cygport almostall
>>> Preparing binutils-2.33.1-1.x86_64
>>> Unpacking source binutils-2.33.1.tar.xz
>>> Preparing working source directory
...
>>> Creating source patches
0 files changed
>>> Creating source package
binutils-2.33.1-1.src/
binutils-2.33.1-1.src/binutils-2.33.1.tar.xz
binutils-2.33.1-1.src/binutils.cygport
>>> binutils requires: cygwin libgcc1
and you can also test the build:
$ cygport binutils.cygport check
=== binutils Summary ===
# of expected passes 136
# of unexpected failures 1
# of expected failures 1
# of unsupported tests 5
I notice an hang at the end of the test, but the check seems completed, co it could be to other factors that I will not investigate.
I am working on a package which includes C code from third-party library (SUNDIALS). The package compiles and works (i.e., is able to solve a test ODE) with the following Makevars file performing static linking
CXX=clang++
PKG_CPPFLAGS = -I../inst/include
PKG_LDFLAGS = /usr/local/lib
PKG_LIBS= $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) $(PKG_LDFLAGS)/libsundials_cvode.a $(PKG_LDFLAGS)/libsundials_nvecserial.a
However, a slightly modified version (based on the example in R-Exts, i.e. -
PKG_LIBS = -L$(XML_DIR)/lib -lxml2) of Makevars (below) fails
CXX=clang++
PKG_CPPFLAGS = -I../inst/include
PKG_LDFLAGS = /usr/local/lib
PKG_LIBS= $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) -L$(PKG_LDFLAGS) -lsundials_cvode -lsundials_nvecserial -lm
fails with the following error message.
Error: package or namespace load failed for ‘Rcppsbmod’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcppsbmod/libs/Rcppsbmod.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcppsbmod/libs/Rcppsbmod.so, 6): Library not loaded: libsundials_cvode.3.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcppsbmod/libs/Rcppsbmod.so
Reason: image not found
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcppsbmod’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcppsbmod’
Exited with status 1.
I am not sure why it is looking for the libraries in another location when I am specifying PKG_LDFLAGS as /usr/local/lib.
As an aside, the test example which comes which the SUNDIALS package compiles and works with the following command
gcc -Wall cvRoberts_dns.c -o cvRoberts_dns.exe -I/usr/local/include -L/usr/local/lib/ -lsundials_cvode -lsundials_nvecserial -lm
So, I know that the library is installed properly and correct files (for linking) are available at /usr/local/lib location.
The entire package source code can be found at - https://github.com/sn248/Rcppsbmod
Any help or guidance will be highly appreciated!
System-wide dynamic linking, as in your second use case which fails, requires the cooperation of the dynamic linker on your system.
That means after build and copyring the libraries to /usr/local/lib you must typically run sudo ldconfig to update the linker cache.
You can check if the libraries are know by grep'ing through the output of ldconfig -p. On my system, no sundials:
edd#rob:~$ ldconfig -p | grep sundials
edd#rob:~$
Relatedly you can (locally) use different directories by declaring them in
/etc/ld.so.conf.d/somefile.conf -- but that is of course not portable and would not help you with a package designated for CRAN.
The use of static libraries you build as part of your package as in your first example would work as it does not require any system assistance. It just takes longer the build the libraries each time.
I am fighting with similar issues, c.f. Runtime linking R-extension on MacOS. My current workaround is to set the rpath at compile time. In your case that would mean:
CXX=clang++
PKG_CPPFLAGS = -I../inst/include
PKG_LDFLAGS = /usr/local/lib
PKG_LIBS= $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) -L$(PKG_LDFLAGS) -lsundials_cvode -lsundials_nvecserial -lm -Wl,-rpath,$(PKG_LDFLAGS)
However, this does not fix your problems. Comparing the error messages I see one difference: In your case the library libsundials_cvode.3.dylib is not found, while in my case it is #rpath/libaf.3.dylib. This means that the library you installed identifies itself as libsundials_cvode.3.dylib. You can check this with
$ otool -L /usr/local/lib/libsundials_cvode.3.dylib
/usr/local/lib/libsundials_cvode.3.dylib:
/usr/local/opt/sundials/lib/libsundials_cvode.3.dylib (compatibility version 3.0.0, current version 3.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
In your case the second output line should not contain an absolute path but only the basename of the library. My installation uses brew, which typically uses absolute paths as library names. In some trivial tests I had no problem with linking an R extension with these libraries.
I see several possibilities:
Try SUNDIAL from brew.
Adjust the library path in your installed libraries with
install_name_tool -id /usr/local/lib/libsundials_cvode.3.dylib /usr/local/lib/libsundials_cvode.3.dylib
to use absolute paths.
Adjust the library path in your installed libraries with
install_name_tool -id '#rpath/libsundials_cvode.3.dylib' /usr/local/lib/libsundials_cvode.3.dylib
and set rpath as above.
Adjust the name of the library your R extension is looking for with this addition to Makevars
all: $(SHLIB)
#if command -v install_name_tool; then install_name_tool -change libsundials_cvode.3.dylib /usr/local/lib/libsundials_cvode.3.dylib $(SHLIB); fi
This is what I'm doing:
SDK_URL=https://github.com/phracker/MacOSX-SDKs/releases/download/10.13/MacOSX10.10.sdk.tar.xz
git clone "https://github.com/tpoechtrager/osxcross.git" osxcross
mkdir -p osxcross/tarballs
curl -sSL "$SDK_URL" -o "osxcross/tarballs/MacOSX10.10.sdk.tar.xz"
cd osxcross && UNATTENDED=1 ./build.sh
I thought I wouldn't need anything else to compile but then I get this error when building the project:
/home/travis/osxcross/target/bin/i386-apple-darwin14-c++ -o platform/osx/sem_osx.osx.tools.32.o -c -g3 -DDEBUG_ENABLED -DDEBUG_MEMORY_ENABLED -w -DFT2_BUILD_LIBRARY -DZLIB_DEBUG -DFREETYPE_ENABLED -DDEBUG_MEMORY_ALLOC -DSCI_NAMESPACE -DENABLE_DEPRECATED -DAPPLE_STYLE_KEYS -DUNIX_ENABLED -DGLES2_ENABLED -DOSX_ENABLED -mmacosx-version-min=10.9 -DTOOLS_ENABLED -DGDSCRIPT_ENABLED -DMINIZIP_ENABLED -DXML_ENABLED -DGLEW_STATIC -DGLEW_ENABLED -Icore -Icore/math -Ieditor -Idrivers -I. -Iplatform/osx -Ithirdparty/zlib -Ithirdparty/glew -Ithirdparty/freetype -Ithirdparty/freetype/include -Ithirdparty/libpng platform/osx/sem_osx.cpp
osxcross: error: cannot find libc++ headers
osxcross: error: while detecting target
I don't see anything related to the libc++ path in the readme file, the only thing that came out when googling for a solution is that it could be a bug in clang, but I'm not sure.
This is the output when I try to build on macOS passing -H to clang:
#include "..." search starts here:
#include <...> search starts here:
core
core/math
editor
drivers
.
platform/osx
thirdparty/zlib
thirdparty/glew
thirdparty/freetype
thirdparty/freetype/include
thirdparty/libpng
/Users/user/Downloads/osxcross-master/target/bin/../SDK/MacOSX10.13.sdk/usr/include/c++/v1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/Users/user/Downloads/osxcross-master/target/bin/../SDK/MacOSX10.13.sdk/usr/include
/Users/user/Downloads/osxcross-master/target/bin/../SDK/MacOSX10.13.sdk/System/Library/Frameworks (framework directory)
End of search list.
I tried to compile atk 2.7.91 from source. Since I am working on an older ubuntu system there are no recent packages for the required glib version. So I just downloaded glib 2.35.8 and did successfully ./configure and make for it (I don't want to install it system-wide so I didn't do make install).
Suppose this glib is in /foobar/glib-2.35.8. Now I cd to /foobar/atk-2.7.91 and export the PKG_CONFIG_PATH: export PKG_CONFIG_PATH=/foobar/glib-2.35.8:$PKG_CONFIG_PATH.
Then
pkg-config --modversion glib-2.0
tells me:
2.35.8
But when I do ./configure I get the error message:
checking for GLIB - version >= 2.31.2... no
*** Could not run GLIB test program, checking why...
*** The test program failed to compile or link. See the file config.log for the
*** exact error that occured. This usually means GLIB is incorrectly installed.
configure: error:
*** GLIB 2.31.2 or better is required. The latest version of
*** GLIB is always available from ftp://ftp.gtk.org/. If GLIB is installed
*** but not in the same location as pkg-config add the location of the file
*** glib-2.0.pc to the environment variable PKG_CONFIG_PATH.
cat config.log |grep glib gives:
configure:12143: checking for GLIB - version >= 2.31.2
configure:12258: gcc -o conftest -g -O2 -Wall -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include -DG_DISABLE_SINGLE_INCLUDES -DATK_DISABLE_SINGLE_INCLUDES conftest.c -L/usr/local/lib -lgobject-2.0 -lglib-2.0 >&5
conftest.c:25:18: fatal error: glib.h: No such file or directory
| #include <glib.h>
| fclose (fopen ("conf.glibtest", "w"));
| if ((glib_major_version != 2) ||
| (glib_minor_version != 35) ||
| (glib_micro_version != 8))
| printf("\n*** 'pkg-config --modversion glib-2.0' returned %d.%d.%d, but GLIB (%d.%d.%d)\n",
| glib_major_version, glib_minor_version, glib_micro_version);
| printf ("*** to remove the old version of GLib. You may also be able to fix the error\n");
| else if ((glib_major_version != GLIB_MAJOR_VERSION) ||
| (glib_minor_version != GLIB_MINOR_VERSION) ||
| (glib_micro_version != GLIB_MICRO_VERSION))
| printf("*** GLIB header files (version %d.%d.%d) do not match\n",
| GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION);
| glib_major_version, glib_minor_version, glib_micro_version);
| if ((glib_major_version > major) ||
| ((glib_major_version == major) && (glib_minor_version > minor)) ||
| ((glib_major_version == major) && (glib_minor_version == minor) && (glib_micro_version >= micro)))
| printf("\n*** An old version of GLIB (%u.%u.%u) was found.\n",
| glib_major_version, glib_minor_version, glib_micro_version);
| printf("*** You need a version of GLIB newer than %u.%u.%u. The latest version of\n",
| printf("*** GLIB is always available from ftp://ftp.gtk.org.\n");
| printf("*** of GLIB, but you can also set the PKG_CONFIG environment to point to the\n");
configure:12304: gcc -o conftest -g -O2 -Wall -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include -DG_DISABLE_SINGLE_INCLUDES -DATK_DISABLE_SINGLE_INCLUDES conftest.c -L/usr/local/lib -lgobject-2.0 -lglib-2.0 >&5
conftest.c:25:18: fatal error: glib.h: No such file or directory
| #include <glib.h>
| return ((glib_major_version) || (glib_minor_version) || (glib_micro_version));
*** GLIB 2.31.2 or better is required. The latest version of
*** GLIB is always available from ftp://ftp.gtk.org/. If GLIB is installed
*** glib-2.0.pc to the environment variable PKG_CONFIG_PATH.
ac_cv_env_PKG_CONFIG_PATH_value=/foobar/glib-2.35.8/:
GLIB_CFLAGS=''
GLIB_COMPILE_RESOURCES=''
GLIB_GENMARSHAL=''
GLIB_LIBS=''
GLIB_MKENUMS=''
GLIB_PACKAGES='gobject-2.0'
GLIB_REQUIRED_VERSION='2.31.2'
PKG_CONFIG_PATH='/foobar/glib-2.35.8/:'
Any idea what's wrong here and how to fix it?
SHORT ANSWER
As (almost) always the Manual is your friend. Try taking a look at man pkg-config you'll see it's the .pc files that pkg-config needs to perform it's job. glib-2.0.pc in your case. Unfortunately it's not as easy as just pointing to the location, where it is stored, but leave that for the long answer at the end and take a look at the manual page for a while first.
pkg-config retrieves information about packages from special
metadata files. These files are named after the package, and has a
.pc extension. On most systems, pkg-config looks in and for these
files. It will additionally look in the colon-separated (on Windows,
semicolon-separated) list of directories specified by the
PKG_CONFIG_PATH environment variable.
The package name specified on the pkg-config command line is
defined to be the name of the metadata file, minus the .pc extension.
If a library can install multiple versions simultaneously, it must
give each version its own name (for example, GTK 1.2 might have
the package name "gtk+" while GTK 2.0 has "gtk+-2.0").
I hope you found the funny
On most systems, pkg-config looks in and for these files
line. The result may differ on yours system, but on mine it actually displays it that way, which is most probably a bug.
Nevertheless you can find out the compiled in standard directories by running
pkg-config --variable pc_path pkg-config which for example prints
/usr/local/lib/pkgconfig:/usr/local/lib/pkgconfig/i486-linux-gnu:/usr/local/share/pkgconfig:/usr/lib/pkgconfig:/usr/lib/pkgconfig/i486-linux-gnu:/usr/share/pkgconfig
on my system.
LONG ANSWER
To get back to your original question, taking a look at an example .pc file might best explain why your first effort was in vain.
As an example here the contents of the glib-2.0.pc file on my system:
prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
glib_genmarshal=glib-genmarshal
gobject_query=gobject-query
glib_mkenums=glib-mkenums
Name: GLib
Description: C Utility Library
Version: 2.24.2
Libs: -L${libdir} -lglib-2.0
Libs.private:
Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include
As you will hopefully see the whole pathes are all hardwired. Don't get confused by ${libdir} ... and the like. Taking a closer look you will see they are all constructed from prefix=/usr in the first line.
The reason trying to just point PKG_CONFIG_PATH to the build directory of your glib won't work as the path specified in the .pc ist the installation directory and not the location of your build directory.
That's why your pkg-config --modversion test ran just fine: The .pc file was indeed found and contained the given information, but the compilation failed: the .pc file was found as in the first case, but the pathes given in the .pc file were simply wrong.
No one can forbid you to just change the directories given in the .pc to any path you like, so in fact you could make the fresh built library work in its build directory by manually fixing the pathes given in the .pc file.
At least if the library itself doesn't contain any hardwired pathes, but that would only be a problem at runtime not while linking.
To even solve the last puzzle - how the the hell could the .pc file know where it is going to be installed to give the right prefix?
Just take a look at your source directory.
Acompanying your glib-2.0.pc file you'll find a file called glib-2.0.pc.in there, with content like that given below:
prefix=#prefix#
exec_prefix=#exec_prefix#
libdir=#libdir#
includedir=#includedir#
glib_genmarshal=glib-genmarshal
gobject_query=gobject-query
glib_mkenums=glib-mkenums
Name: GLib
Description: C Utility Library
Version: #VERSION#
Requires.private: #PCRE_REQUIRES#
Libs: -L${libdir} -lglib-2.0 #INTLLIBS#
Libs.private: #G_THREAD_LIBS# #G_LIBS_EXTRA# #PCRE_LIBS# #INTLLIBS# #ICONV_LIBS#
Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include #GLIB_EXTRA_CFLAGS#
The whole #....# placeholders where filled in at configure time, when you were running configure. i.e. #prefix# was filled with the argument given as --prefix= on the command line, while others like #NTLLIBS# were filled with parameters detected by the configure script.
You need to install the glib somewhere, you can't just point ATK at the Glib build directory. You can install it somewhere private like ~/install by
./configure --prefix=/home/<username>/install
(configure doesn't like ~ IIRC)