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

Add PC files for library #517

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Conversation

taozuhong
Copy link
Contributor

No description provided.

ctlib.pc.in Outdated Show resolved Hide resolved
ctlib.pc.in Outdated Show resolved Hide resolved
ctlib.pc.in Outdated
Requires.private: libssl, libcrypto libiconv
Cflags: -I${includedir}/freetds
Libs: -L${libdir} -lct
Libs.private: -ladvapi32 -lkernel32 -lshell32 -lcrypt32 -lws2_32 -lsecur32
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put these files in CMakeLists.txt within a if(WIN32)...endif(WIN32) condition, they are only useful and working for Windows.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the pkg-config file works for Linux/macOS/MINGW(Windows), not windows only.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the Libs.private should update with the build tool, because it will change with the operating system.

ctlib.pc.in Outdated Show resolved Hide resolved
@freddy77
Copy link
Contributor

freddy77 commented Dec 3, 2023

Looking at initial issue and https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-freetds/PKGBUILD I suppose we should first address Autoconf instead of CMake (not saying CMake should not be supported!).

@freddy77
Copy link
Contributor

@taozuhong how is the state of this PR?

@taozuhong
Copy link
Contributor Author

For CMake, it's OK to be merged. autotool not yet.

@freddy77
Copy link
Contributor

I tried to test it but it does not work. I compiled installed and tested, something like

# cleanup
$ rm -rf cmake
$ rm -rf "$HOME/ftds_install"

# build and install cmake
$ mkdir cmake
$ cd cmake
$ cmake "-DCMAKE_INSTALL_PREFIX:PATH=$HOME/ftds_install" ..
$ make install

# prepare test program
$ cat <<EOF > test.c
#include <stdio.h>
#include <sqldb.h>

int main(void)
{
   printf("login is %p\n", dblogin());
}
EOF

$ export PKG_CONFIG_PATH=$HOME/ftds_install/lib64/pkgconfig

$ gcc -O2 -Wall $(pkg-config --cflags --libs dblib)

compilation fails with

Package iconv was not found in the pkg-config search path.
Perhaps you should add the directory containing `iconv.pc'
to the PKG_CONFIG_PATH environment variable
Package 'iconv', required by 'dblib', not found
test.c:2:10: fatal error: sqldb.h: No such file or directory
    2 | #include <sqldb.h>
      |          ^~~~~~~~~
compilation terminated.

after removing iconv from dependency (only for Windows)

test.c:2:10: fatal error: sqldb.h: No such file or directory
    2 | #include <sqldb.h>
      |          ^~~~~~~~~
compilation terminated.

checking what pkg-config thinks

$ pkg-config --cflags --libs dblib
-I/home/fziglio/ftds_install/include/freetds -L/home/fziglio/ftds_install/lib/ -lsybdb 

however includes are not there

$ find /home/fziglio/ftds_install/include/freetds
/home/fziglio/ftds_install/include/freetds
/home/fziglio/ftds_install/include/freetds/version.h

If I pass a specific directory to cmake is even worse, for instance

cmake -DCMAKE_INSTALL_INCLUDEDIR=inc/ftds "-DCMAKE_INSTALL_PREFIX:PATH=$HOME/ftds_install" ..

Trying to understand how to better produce PC files with CMake, it's not that easy. Maybe better to start with Autoconf?

@taozuhong
Copy link
Contributor Author

taozuhong commented Dec 25, 2023

CMake to generate pc file works with MSYS2 environment, I have tested it.

# build freetds
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/ucrt64 ..
ninja install

# build example app
..........

image

@freddy77
Copy link
Contributor

freddy77 commented Jan 4, 2024

I managed to reproduce your settings. Yes, it works, but because you installed on default directory so you don't need -I setting, not because the -I directory you specify is correct. Try to pass -DCMAKE_INSTALL_PREFIX=/ucrt64addon, adjust PKG_CONFIG_PATH and it won't compile. I'll try to find some better solution this evening.

@taozuhong
Copy link
Contributor Author

U r right, it's not the final solution, it need be update with new plan(ctlib/dblib/etc).

BTW, could export libtds library directly(libtds.pc)?

@freddy77
Copy link
Contributor

freddy77 commented Jan 6, 2024

This commit improves a bit, at least if you set different defaults freddy77@2fe6778.

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.

2 participants