Missing libraries for compiling examples

60 views
Skip to first unread message

Chainey Ryan

unread,
Feb 5, 2025, 10:26:12 AMFeb 5
to MAGMA User
Hi,

I was trying to run the example program example_v2.cpp and ran into an error 

"c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot find -lmagma_config
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot find -lmagma_v2"

Looking through the magma folders I can see that there are lmagma_config.h and lmagma_v2.h files but no library files for either.

I'm attaching the makefile in question

Did my project not build correctly?
Thanks
Make_example_v2

Natalie Beams

unread,
Feb 5, 2025, 10:36:21 AMFeb 5
to MAGMA User, chocolat...@gmail.com
Hi,

In your attached makefile, -lmagma_config and -lmagma_v2 are explicitly added to LIBS, which is why it's looking for those non-existent files.
But I don't see that in example/Makefile. Did you add it? I see there is another LIBS definition in your file that is commented out -- did you try that one?

Thanks,
Natalie

Chainey Ryan

unread,
Feb 5, 2025, 11:15:29 AMFeb 5
to MAGMA User, Natalie Beams, Chainey Ryan
Hi Natalie,

So I will admit I am new to creating makefiles so I created my own to understand what the file was doing.
I have tried running the makefile I created with the other LIBS definition. Doing so gives me the errors shown below

I will try to set up the provided makefile and see if that works

"C:\Users\chainey\AppData\Local\Temp\cckMDaLj.o:example_v2.cpp:(.text+0x6806): undefined reference to `magma_setmatrix_internal'
C:\Users\chainey\AppData\Local\Temp\cckMDaLj.o:example_v2.cpp:(.text+0x6824): undefined reference to `magma_malloc'
C:\Users\chainey\AppData\Local\Temp\cckMDaLj.o:example_v2.cpp:(.text+0x6841): undefined reference to `magma_malloc_cpu'
C:\Users\chainey\AppData\Local\Temp\cckMDaLj.o:example_v2.cpp:(.text+0x685e): undefined reference to `magma_malloc_cpu'
C:\Users\chainey\AppData\Local\Temp\cckMDaLj.o:example_v2.cpp:(.text+0x6a41): undefined reference to `magma_free_cpu'
C:\Users\chainey\AppData\Local\Temp\cckMDaLj.o:example_v2.cpp:(.text+0x6b9f): undefined reference to `magma_zgesv'
C:\Users\chainey\AppData\Local\Temp\cckMDaLj.o:example_v2.cpp:(.text+0x6bd0): undefined reference to `magma_free_cpu'
C:\Users\chainey\AppData\Local\Temp\cckMDaLj.o:example_v2.cpp:(.text+0x6bdb): undefined reference to `magma_free_cpu'
C:\Users\chainey\AppData\Local\Temp\cckMDaLj.o:example_v2.cpp:(.text+0x6be6): undefined reference to `magma_free_cpu'
C:\Users\chainey\AppData\Local\Temp\cckMDaLj.o:example_v2.cpp:(.text+0x6ce4): undefined reference to `magma_queue_create_internal'
C:\Users\chainey\AppData\Local\Temp\cckMDaLj.o:example_v2.cpp:(.text+0x6d6f): undefined reference to `magma_zgesv_gpu'
C:\Users\chainey\AppData\Local\Temp\cckMDaLj.o:example_v2.cpp:(.text+0x6db8): undefined reference to `magma_queue_destroy_internal'
C:\Users\chainey\AppData\Local\Temp\cckMDaLj.o:example_v2.cpp:(.text+0x6ddb): undefined reference to `magma_free_internal'
C:\Users\chainey\AppData\Local\Temp\cckMDaLj.o:example_v2.cpp:(.text+0x6dfe): undefined reference to `magma_free_internal'
C:\Users\chainey\AppData\Local\Temp\cckMDaLj.o:example_v2.cpp:(.text+0x6e09): undefined reference to `magma_free_cpu'
C:\Users\chainey\AppData\Local\Temp\cckMDaLj.o:example_v2.cpp:(.text+0x6e23): undefined reference to `magma_init'
C:\Users\chainey\AppData\Local\Temp\cckMDaLj.o:example_v2.cpp:(.text+0x6e78): undefined reference to `magma_finalize'
collect2.exe: error: ld returned 1 exit status
Make_example_v2:25: recipe for target 'example_v2' failed"

Natalie Beams

unread,
Feb 5, 2025, 11:31:42 AMFeb 5
to MAGMA User, chocolat...@gmail.com, Natalie Beams
No worries!  It looks like it's not finding the libmagma.so file when linking.

Your LDFLAGS has -L$(MAGMA_DIR)/build/lib/Debug for the MAGMA library directory -- can you confirm that 
libmagma.so is present in this location? If not, that path should be updated to wherever the library is installed.

I see LDFLAGS also includes -L$(MAGMA_DIR)/include -- the include/ directory is just for headers, it
doesn't need to included with the -L (for library directories).

-- Natalie



Chainey Ryan

unread,
Feb 5, 2025, 1:20:10 PMFeb 5
to MAGMA User, Natalie Beams, Chainey Ryan
I removed   -L$(MAGMA_DIR)/include from the library directories,

However I do not see  libmagma.so anywhere in my magma folder

Chainey Ryan

unread,
Feb 5, 2025, 1:20:15 PMFeb 5
to MAGMA User, Natalie Beams, Chainey Ryan
Also I tried compiling and running the code using the provided makefile and it does not seem to actually create the example_v2.exe file.
I believe it is just silently failing

attached are the modified makefile and my tasks.json

On Wednesday, February 5, 2025 at 12:31:42 PM UTC-4 Natalie Beams wrote:
tasks.json
Makefile_example_v2

Natalie Beams

unread,
Feb 5, 2025, 2:25:50 PMFeb 5
to MAGMA User, chocolat...@gmail.com, Natalie Beams
I think we need to back up for a moment. You should definitely have libmagma.so somewhere if the library was built successfully.

Can you share:
 -  your process for building the MAGMA library (your configuration options, commands you ran, etc.)
 - the output you got from those commands (any errors?)

I think that also explains your second question, about the Makefile that's in the example/ directory. That Makefile uses pkg-config, which 
I believe will only be created if you do `make install`. Then the config should end up in the same location as the library (MAGMA_INSTALL_DIR/lib).

-- Natalie

Chainey Ryan

unread,
Feb 6, 2025, 1:49:04 PMFeb 6
to MAGMA User, Natalie Beams, Chainey Ryan
So I don't have pkg-config so it sounds like I missed a step in the installation process.

I am using windows, I have CMAKE 3.24.1, no fortran, cuda 12.8, the latest version of intelOneAPI mkl, and the latest version of visual studio 2022.

I generated everything in CMAKE, then built the project in Visual Studio. Attached is the CMAKE window
In Visual Studio, I do not have the output anymore but I believe it was something along the lines of 620 built successfully, 11 failed, 4 skipped. Following another post in this forum I was under the impression that this was fine.

I'm assuming there is another install step I need to do?
Capture.PNG

Andrew Cunningham

unread,
Feb 6, 2025, 3:00:46 PMFeb 6
to Chainey Ryan, MAGMA User
Make sure you have built the “Release” configuration
Right click on the “INSTALL” project and “build” that project
That should create a MAGMA “installation" in the C:\MAGMA folder
In you own projects you would reference the include are lib areas

1>------ Build started: Project: INSTALL, Configuration: Release x64 ------
1>1>
1>-- Install configuration: "Release"
1>-- Installing: D:/dev/magma-2.9.0/install/lib/magma.lib
Etc….

-- 
You received this message because you are subscribed to the Google Groups "MAGMA User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to magma-user+...@icl.utk.edu.
To view this discussion visit https://groups.google.com/a/icl.utk.edu/d/msgid/magma-user/5b6c127d-ddcc-4711-a1d5-41ad753cd5aen%40icl.utk.edu.
<Capture.PNG>

Andrew Cunningham

unread,
Feb 6, 2025, 5:47:50 PMFeb 6
to Chainey Ryan, MAGMA User

Since you are on Windows and using Visual Studio , the simplest approach , rather than messing with Makefiles and mingw, would be to create a new console project in visual studio, add your source files, and reference the MAGMA include path and MAGMA libraries in the INSTALL location. 

Use one of the MAGMA testing_ Visual Studio projects as a reference for C++ include, pre-processing options and libraries  will save some time. You will need to adjust some paths



On Feb 6, 2025, at 9:20 AM, Chainey Ryan <chocolat...@gmail.com> wrote:

Chainey Ryan

unread,
Feb 7, 2025, 10:08:07 AMFeb 7
to MAGMA User, AndrewC, MAGMA User, Chainey Ryan
Hey Andrew,

I have built the release configuration but I do not see the INSTALL project.
Is that also in visual studio?

Andrew Cunningham

unread,
Feb 7, 2025, 10:08:15 AMFeb 7
to Ryan Chainey, User MAGMA, Ryan Chainey
  It should be in the list of visual studio projects in your magma.sln . I am not sure how your VS solution could  be generated without the INSTALL project present.

On Feb 7, 2025, at 5:22 AM, Chainey Ryan <chocolat...@gmail.com> wrote:

Hey Andrew,

Chainey Ryan

unread,
Feb 7, 2025, 1:56:56 PMFeb 7
to MAGMA User, AndrewC, User MAGMA, Chainey Ryan
That's my bad, I was unfamiliar with Visual Studio.

I ran the install and got the following

13>------ Build started: Project: INSTALL, Configuration: Release x64 ------
13>-- Install configuration: "Release"
13>-- Installing: C:/MAGMA/lib/magma.lib
13>-- Installing: C:/MAGMA/lib/magma_sparse.lib
13>-- Installing: C:/MAGMA/include/magma_config.h
13>-- Installing: C:/MAGMA/include/magma.h (and a bunch more libraries)

But do not see the libmagma.so file that Natalie previously mentioned.

Is that an issue?

Natalie Beams

unread,
Feb 7, 2025, 1:59:15 PMFeb 7
to MAGMA User, chocolat...@gmail.com, AndrewC, User MAGMA
Sorry, I don't have any experience building MAGMA on Windows. It looks like `lib/magma.lib` is the file you need?

I'm glad Andrew has jumped in with the Windows expertise, thanks Andrew :) 


-- Natalie

Andrew Cunningham

unread,
Feb 7, 2025, 2:25:15 PMFeb 7
to Chainey Ryan, MAGMA User, nbe...@icl.utk.edu
Chainey,
All looks good in your INSTALL step.

There has been confusion in this thread. I think Natalie was assuming you were on Linux.

libmagma.so is Linux specific.  On Linux dynamic libraries are .so and static libraries are .a and prefixed with “lib"

On Windows dynamic libraries are .DLL and static libraries are .LIB

So the libraries you would be linking against would be magma.lib and magma_sparse.lib


So, I am not really sure what you are trying to do now?


The absolutely simplest way to get going is a bit crude and the project will be overwritten if you generate from CMake again. But….

- Pick one of the testing_xxx projects in Visual Studio  , for example, testing_zgemm
- Right-click on the project and “Set as Startup Project”
- Hit F5 to run the project
- Check it runs!!
- Add your .cpp file to that project  (drag and drop)
- Remove the testing_zgemm.cpp file from the project ( don’t delete it)
- Build your and run ( you can set to Debug or RelWithDebInfo to debug)

Chainey Ryan

unread,
Feb 11, 2025, 11:12:58 AMFeb 11
to MAGMA User, AndrewC, MAGMA User, Natalie Beams, Chainey Ryan
Oh ok there was definitely some confusion with the whole linux/windows thing.

OK so I tried to set up the project in the way you recommended and it's been weird.

At first  testing_zgemm would not build in visual studio despite me seeing the testing_zgemm.exe in the testing/release folder.
I kept getting the error: "The code execution cannot proceed because mkl_sequential2.dll was not found. Reinstalling the program may fix the problem"

I checked and mkl_sequential2.dll is present in both "C:\Program Files (x86)\Intel\oneAPI\mkl\latest\bin" and "C:\Program Files (x86)\Intel\oneAPI\mkl\latest\bin".

 I installed the rest of the intel oneAPI base package and initialized the oneAPI variables as per these instructuctions:

This allowed me to build the testing_zgemm project in visual studio but the .exe still will not run giving me the same error :
"The code execution cannot proceed because mkl_sequential2.dll was not found. Reinstalling the program may fix the problem"

A mistake on my end is that I kept the debug version of my magma build as well as the release version which I think is causing some issues. I will be cleaning up and rebuilding the project

Andrew Cunningham

unread,
Feb 11, 2025, 11:35:24 AMFeb 11
to Ryan Chainey, User MAGMA, Natalie Beams, Ryan Chainey
You need to add the MKL directory to your PATH so that the DLLs can be found at runtime.
Edit the environment variables for your account and modify the PATH variable to include C:\Program Files (x86)\Intel\oneAPI\mkl\latest\bin

Ps you need to restart visual studio after making these changes

Debug and release builds are completely separate, you can switch back and forth at will.


On Feb 11, 2025, at 8:11 AM, Chainey Ryan <chocolat...@gmail.com> wrote:

Oh ok there was definitely some confusion with the whole linux/windows thing.

Andrew Cunningham

unread,
Feb 11, 2025, 11:35:30 AMFeb 11
to Ryan Chainey, User MAGMA, Natalie Beams, Ryan Chainey
And just a point regarding the “setvars.bat”. That typically only applies when building from the command line.  That is, you open a command prompt then execute setvars.bat to have a build environment ready with all the intel tools available. That is generally separate from the visual studio build environment.

On Feb 11, 2025, at 8:27 AM, Andrew Cunningham <ad...@a-cunningham.com> wrote:



Chainey Ryan

unread,
Feb 11, 2025, 1:11:01 PMFeb 11
to MAGMA User, AndrewC, User MAGMA, Natalie Beams, Chainey Ryan
That worked!

Thank you so much for the help

Reply all
Reply to author
Forward
0 new messages