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

ForeignFunctions example error with libmps #3374

Open
mahrud opened this issue Jul 21, 2024 · 8 comments
Open

ForeignFunctions example error with libmps #3374

mahrud opened this issue Jul 21, 2024 · 8 comments
Assignees
Labels
build issue platform specific issues involving compiling M2, generating examples, or running tests

Comments

@mahrud
Copy link
Member

mahrud commented Jul 21, 2024

This is happening on Debian 12.6:

$ cat usr-dist/common/share/doc/Macaulay2/ForeignFunctions/example-output/_foreign__Symbol.errors
-- -*- M2-comint -*- hash: 2759357810293599536

i1 : mps = openSharedLibrary "mps"

o1 = mps

o1 : SharedLibrary

i2 : cplxT = foreignStructType("cplx_t", {"r" => double, "i" => double})

o2 = cplx_t

o2 : ForeignStructType

i3 : foreignSymbol(mps, "cplx_i", cplxT)

o3 = HashTable{"i" => 1}
               "r" => 0

o3 : ForeignObject of type cplx_t

i4 : foreignSymbol("cplx_i", cplxT)
stdio:4:1:(3): error: /net/st1/export/clusterhome/sayrafi/M2/M2/BUILD/build/usr-dist/x86_64-Linux-Debian-12/bin/M2-binary: undefined symbol: cplx_i

Here is the library file:

dpkg -S /usr/lib/x86_64-linux-gnu/libmps.so.3
libmps3:amd64: /usr/lib/x86_64-linux-gnu/libmps.so.3

cc: @d-torrance

@d-torrance
Copy link
Member

Am I correct in assuming that M2 was linked with mpsolve as a static instead of dynamic library for this build?

This is a long standing issue -- see also #2919. I should probably just use a different example for foreignSymbol.

@mahrud
Copy link
Member Author

mahrud commented Jul 22, 2024

mpsolve was built by our build script and linked statically, but there are shared libraries available:

$ find /usr/lib/x86_64-linux-gnu/libmps*
/usr/lib/x86_64-linux-gnu/libmps.so.3
/usr/lib/x86_64-linux-gnu/libmps.so.3.0.1

libmps-dev is not installed, but that shouldn't be required, right?

@d-torrance
Copy link
Member

It is required for the unversioned libmps.so.

@d-torrance
Copy link
Member

d-torrance commented Jul 22, 2024

But the issue is that the 2-argument foreignSymbol looks for symbols in the dynamic libraries that M2 is already linked against. And if we link against mpsolve statically, then it won't find cplx_i.

@mahrud
Copy link
Member Author

mahrud commented Jul 22, 2024

Oh, I see.

It is required for the unversioned libmps.so.

I did make a symlink of a libmps.so.3 to .local/lib/libmps.so!

@mahrud
Copy link
Member Author

mahrud commented Jul 22, 2024

I'm happy to either close this or keep it open until you use a different example for foreignSymbol. What is a library that we're always dynamically linked with? I can't think of an obvious choice.

@mahrud mahrud added the build issue platform specific issues involving compiling M2, generating examples, or running tests label Jul 22, 2024
@d-torrance
Copy link
Member

Let's keep it open. I couldn't think of a better example back when I wrote this documentation, but there certainly might be one.

@mahrud
Copy link
Member Author

mahrud commented Aug 10, 2024

(Not trying to rush you, I'm just going around assigning issues to people just to figure out which issues have no ownership)

d-torrance added a commit to d-torrance/M2 that referenced this issue Oct 2, 2024
It's in the C standard library, so we know that it will be available.

Closes: Macaulay2#3374
d-torrance added a commit to d-torrance/M2 that referenced this issue Oct 2, 2024
It's in the C standard library, so we know that it will be available.

Closes: Macaulay2#3374
d-torrance added a commit to d-torrance/M2 that referenced this issue Oct 14, 2024
It's in the C standard library, so we know that it will be available.

Closes: Macaulay2#3374
d-torrance added a commit to d-torrance/M2 that referenced this issue Oct 15, 2024
It's in the C standard library, so we know that it will be available.

Closes: Macaulay2#3374
d-torrance added a commit to d-torrance/M2 that referenced this issue Oct 17, 2024
It's in the C standard library, so we know that it will be available.

Closes: Macaulay2#3374
d-torrance added a commit to d-torrance/M2 that referenced this issue Oct 17, 2024
It's in the C standard library, so we know that it will be available.

Closes: Macaulay2#3374
d-torrance added a commit that referenced this issue Oct 19, 2024
It's in the C standard library, so we know that it will be available.

Closes: #3374
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build issue platform specific issues involving compiling M2, generating examples, or running tests
Projects
None yet
Development

No branches or pull requests

2 participants