0

I installed the arblib library using vcpkg and trying to run a simple program from their website (https://arblib.org/setup.html):

#include "arb.h"

int main()
{
    arb_t x;
    arb_init(x);
    arb_const_pi(x, 50 * 3.33);
    arb_printn(x, 50, 0); flint_printf("\n");
    flint_printf("Computed with arb-%s\n", arb_version);
    arb_clear(x);
}

If I use VS 2022 (via creating an empty project with the program), everything works perfectly.

However, when trying to compile with gcc:

gcc test.c -o .\exe\test -LC:\...\vcpkg\installed\x64-windows\lib 
-IC:\...\vcpkg\installed\x64-windows\include -larb -lflint -lmpfr -lgmp

the resulting executable doesn't work (command executed and failed (Exit Code 1)). Compilation goes without errors.

Using the elimination method, I realized that the problem is in the arb_printn function. Probably I'm passing the wrong flags, but I can't figure how to fix the situation.

  • Are you sure the program you are running from the command line is the one you built? There are other programs named "test", and some environments provide one in the default path. If your program works as expected when you build it with VS, but not when you build it from the command line with GCC, then it is unlikely that the problem with the latter build arises from using the library's functions incorrectly. – John Bollinger May 30 '23 at 13:58
  • Yes, I'm sure that I'm running the resulting .exe file. It is important that in one case I create a VC project, and in the other I just have a .c file and run it using the compiler. – Emma Anderson May 30 '23 at 14:22
  • Is the library provided as a DLL? In that case, Windows will look for it in the binary's directory and in the executable search path. Same for other dynamic libraries, too. It is entirely possible for the compiler to find it (because you specified an appropriate `-L` option), but for the system to not find it when you try to run the program. – John Bollinger May 30 '23 at 14:41
  • yes, dll, but in the PATH environment variable there is an address to `C:\...\vcpkg\installed\x64-windows\bin` – Emma Anderson May 30 '23 at 14:51
  • It's not clear what may be happening. I recommend you turn up your compiler's diagnostics (`-Wall -Wextra -pedantic`) and resolve any diagnostics it emits. You may also benefit from running the program under control of `gdb` or another command-line debugger. Turning on some of [GCC's `-fsanitize` options](https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html) may help you determine more precisely what's going wrong. – John Bollinger May 30 '23 at 15:03

0 Answers0