Why isn't Magma 2.5 compilable? - magma

I am trying to compile Magma 2.5 on my laptop with NVIDIA GTX 960M, and it always prompts the linkage problem.
I have upgraded cmake version to thew newest available (3.14.3).
Below is part of the error output.
lib/libmagma_sparse.a(magma_sparse_generated_magma_dsampleselect.cu.o): In function `magma_dsampleselect':
tmpxft_0000080b_00000000-5_magma_dsampleselect.compute_60.cudafe1.cpp:(.text+0x337): undefined reference to `magma_sampleselect::sampleselect_alloc_size(int)'
tmpxft_0000080b_00000000-5_magma_dsampleselect.compute_60.cudafe1.cpp:(.text+0x364): undefined reference to `magma_sampleselect::realloc_if_necessary(void**, int*, int)'
tmpxft_0000080b_00000000-5_magma_dsampleselect.compute_60.cudafe1.cpp:(.text+0x4f0): undefined reference to `magma_sampleselect::sampleselect(double*, double*, double*, int*, int, int, double*)'
lib/libmagma_sparse.a(magma_sparse_generated_magma_dsampleselect.cu.o): In function `magma_dsampleselect_approx':
tmpxft_0000080b_00000000-5_magma_dsampleselect.compute_60.cudafe1.cpp:(.text+0x65a): undefined reference to `magma_sampleselect::realloc_if_necessary(void**, int*, int)'
tmpxft_0000080b_00000000-5_magma_dsampleselect.compute_60.cudafe1.cpp:(.text+0x7e5): undefined reference to `magma_sampleselect::build_searchtree(double const*, double*, int)'
tmpxft_0000080b_00000000-5_magma_dsampleselect.compute_60.cudafe1.cpp:(.text+0x872): undefined reference to `magma_sampleselect::count_buckets(double const*, double const*, int*, int, int)'
tmpxft_0000080b_00000000-5_magma_dsampleselect.compute_60.cudafe1.cpp:(.text+0x8f7): undefined reference to `magma_sampleselect::reduce_counts(int const*, int*, int)'
tmpxft_0000080b_00000000-5_magma_dsampleselect.compute_60.cudafe1.cpp:(.text+0x97e): undefined reference to `magma_sampleselect::sampleselect_findbucket(int*, int, unsigned int*, int*)'
collect2: error: ld returned 1 exit status

Try adding the following files to the libsparse_all target inside CMake.src file:
sparse/blas/magma_dsampleselect_core.cu
sparse/blas/magma_sampleselect.cu
sparse/blas/magma_ssampleselect_core.cu
I have not yet verified this solution due to slow recompilation.

Related

Linker error for global variable [duplicate]

This question already has answers here:
Accesing global variable giving linker error in objective C
(2 answers)
Closed 9 years ago.
I'm making a small, simple application, so I decided to use global variables over Singletons. I'm also only using one.
My app pulls an int from a small preference file, and that is set to the global variable as an NSInteger. The global variable may be changed while the app is running.
AppController.h
#import <Cocoa/Cocoa.h>
extern NSInteger preferenceNumber;
#interface ....
App Controller.m
-(void)someMethod {
...
//fileContents is a string containing the int that is inside the file
preferenceNumber = [fileContents intValue]
...
}
The Linker Errors (2):
Undefined symbols for architecture x86_64:
"_preferenceNumber", referenced from:
-[AppController someMethod1] in AppController.o
-[AppController someMethod2:] in AppController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The bolded parts are the two errors.
What is causing this? What is the simplest, best way to solve it?
Just add one line in your implementation class:-
AppContollr.m
#implementation AppContoller
NSInteger preferenceNumber;

assigning to 'uint8_t *' (aka 'unsigned char *' ) from incompatible type 'void *'

uint8_t *bufferPtr=NULL;
size_t bufferPtrSize=0;
bufferPtr=malloc(bufferPtrSize * sizeof(uint8_t))
I have used this same code in File1.m it is working fine. When I am using this on File2.mm it is giving me assigning to 'uint8_t *' (aka 'unsigned char *' ) from incompatible type 'void *'error.
This is because .mm files aren't treated as normal Objective-C files but as Objective-C++ files, so the type rules of C++ apply here. In C++, if you decide to have a type (in this case you have a void pointer) and then want another type (in your case a char pointer), then you have to explicitly cast them. The way to do this is static_cast<T>() where T is the target type. Ie: uint8_t *bufferPtr = static_cast<uint8_t *>(malloc(bufferPtrSize * sizeof(uint8_t)));

Upgrading XCode caused warning for hex Format Specifier

The following line of code:
[colHeader appendFormat:#"%C", 0x2193];
throws this warning:
Format specifies type 'unsigned short' but the argument has type 'int'
This started appearing when I upgraded to Xcode 4.4 (upgraded compiler?). The warning will drive me nuts...any suggestions on how to remove it? Thanks.
Well, the easiest thing is just to cast it, I guess:
[colHeader appendFormat:#"%C", (ushort) 0x2193];
You can specify that a value is unsigned by appending a "u", e.g., 0x2193u. However, the constant will then be an unsigned int, not an unsigned short, so that won't help you here as you would still get a warning.

extern in objective-C; do they behave differently than C?

I required to share a const value between two files; so rather than keeping a magical number I decided to use a const variable.
So I created a global variable const int viewTag = 100; in my appDelegate.m
Then accessed it as extern const int viewTag; but I got following linker error:
Undefined symbols for architecture i386:
"viewTag", referenced from:
-[xxxViewController launchxxx] in libxxx_iPad.a(xxxViewController.o)
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
But the above thing is perfectly leagal in normal C,C++ env. can anybody throw some light?
Update: putting extern const int viewTag; in header and importing that header works, but I really don't want to do that for a single const int
Try putting:
extern const int viewTag;
in appDelegate.h, then importing this header where you need access to viewTag.
Another way is to use #define viewTag 100 in .pch file.
But I think, the best way is to create .h file with constants and include where you want

error: too many initializers for ‘const __class_type_info_pseudo’

Did anyone ever see this compiler error before:
error: too many initializers for
‘const __class_type_info_pseudo’