You are not logged in.

#1 2024-06-02 19:53:25

dimalmfao
Member
From: Uranus, 42 Phosphate Factory
Registered: 2024-06-01
Posts: 6
Website

Trouble Linking With My Library After PKGBUILD Installation

I'm trying to create my own PKGBUILD, for the AUR, that will be used
as a tool to install my library.

I'm encountering an issue while trying to link my test c file with the library.

gcc main.c -ldimanet -o main

Outputting the following error:

/sbin/ld: cannot find -ldimanet: No such file or directory
collect2: error: ld returned 1 exit status

I've created a PKGBUILD for the library, ensuring that dimanet.c and dimanet.h
are placed in the appropriate directory (/usr/include). Despite this, it seems
like the linker can't find the library.

Here's the PKGBUILD:

pkgname=dimanet
pkgver=1.2
pkgrel=1
pkgdesc="DimaNet is just a bad integration of a neural network library written in pure, ANSI C."
arch=('any')
url="https://github.com/dimalmfao/dimanet"
license=('GPL-3.0')
depends=('gcc')
source=("$pkgname-$pkgver.tar.gz::https://github.com/dimalmfao/dimanet/archive/master.tar.gz")
sha256sums=('SKIP')

prepare() {
  tar -xf "$srcdir/$pkgname-$pkgver.tar.gz" -C "$srcdir/"
}

package() {
  cd "$srcdir/dimanet-master"
  mkdir -p "$pkgdir/usr/include"
  cp dimanet.c dimanet.h "$pkgdir/usr/include/"
}

Last edited by dimalmfao (2024-06-02 19:54:08)

Offline

#2 2024-06-02 20:06:52

loqs
Member
Registered: 2014-03-06
Posts: 18,911

Re: Trouble Linking With My Library After PKGBUILD Installation

The linker would be looking for libdimanet.so or libdimanet.a in the standard linker search paths such as /usr/lib.  The PKGBUILD does not install anything to /usr/lib.

Offline

#3 2024-06-02 20:09:17

dimalmfao
Member
From: Uranus, 42 Phosphate Factory
Registered: 2024-06-01
Posts: 6
Website

Re: Trouble Linking With My Library After PKGBUILD Installation

loqs wrote:

The linker would be looking for libdimanet.so or libdimanet.a in the standard linker search paths such as /usr/lib.  The PKGBUILD does not install anything to /usr/lib.

Can you explain me how to do it the correct way?

Offline

#4 2024-06-02 20:10:19

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: Trouble Linking With My Library After PKGBUILD Installation

And you should not install the source (*.c) files to /usr/include, or really at all.  You have to build the library and install the build library in the PKGBUILD (or ideally in the Makefile and the PKGBUILD will just run make and make install).

Here's a library I wrote:
PKGBUILD
source files, in particular see the Makefile.

Last edited by Trilby (2024-06-02 20:12:13)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2024-06-02 20:12:20

dimalmfao
Member
From: Uranus, 42 Phosphate Factory
Registered: 2024-06-01
Posts: 6
Website

Re: Trouble Linking With My Library After PKGBUILD Installation

Trilby wrote:

And you should not install the source (*.c) files to /usr/include, or really at all.  You have to build the library and install the build library in the PKGBUILD (or ideally in the Makefile and the PKGBUILD will just run make and make install).

Oh, I see. Thanks.

Offline

Board footer

Powered by FluxBB