I tried to build simple kernel module (using source downloaded from developer.sonymobile.com) but after compiling i can't insmod it: Unknown symbol __gnu_mcount_nc so i founded a solution and I wrote another module using assembler and I exported this function. After this module insmoded correctly but I see in lsmod that all modules are permament. I have a problem with simple filesystem (Permission denied - default action when pointer is null), on PC this code works without any errors.
I guess the config is wrong in source code, (probably offset of some fields in structure is another than in device).
Version of built is: 24.0.A.5.14 (downloaded from developer.sonymobile.com site).
Can I do anything to get this same configuration as in device?
I had not /proc/config.gz so I can't get it easily.
Module source:
#include <linux/module.h>
#include <linux/kernel.h>
int __init example_init(void)
{
printk("Hello world!\n");
return 0;
}
void __exit example_exit(void)
{
printk("example module exit\n");
}
module_init(example_init);
module_exit(example_exit);
And I see Hello World! in dmesg but module is still permament.
Source of __gnu_mcount_nc i found here: http://doc.ironwoodlabs.com/arm-arm-none-eabi/html/getting-started/arm-mcount.html
Do you compile with with profile enable -pg flag when you build the kernel module? It looks that way.
The kernel module Makefile for CFLAGS.
Related
I am looking for a way to use cufft.h a CUDA toolkit which perform GPU parallelization of fast fourier transform.
First of all, I downloaded cuda library and cufft through synaptic.
Then I used the sample program from the cufft documentation from NVidia.
my cuda library is located at /usr/local/cuda-9.0 on my laptop.
I added those include :
1 #include <iostream>
2 #include <cstdio>
3 #include "/usr/local/cuda-9.0/include/cuda.h"
4 #include "/usr/local/cuda-9.0/include/cuda_runtime_api.h"
5 #include "/usr/local/cuda-9.0/include/cufft.h"
I compile like this :
g++ -Wall main.cpp -o main
and get undefine references error for each cuda-like functions (cudaMalloc,cudaGetLastError, etc...)
I am pretty young about library implementation and I don't understand what should I do to include properly this cuda-cufft library...
The nvidia documentation talk about filename.cu but I don't know what this is about...
Thank you for your time :)
n.b : I added cuda.h and cuda_runtime_api.h after reading a forum (I forgot which it was). Apparently, only cuda_runtime_api.h is necessary (I tried without cuda.h and get the same errors).
Here is a complete sample code (that doesn't do anything useful) and a sample g++ compile command that will properly compile and link the code:
$ cat t1338.cpp
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cuda_runtime.h>
#include <cufft.h>
int main() {
size_t work_size;
int fft_sz = 32; // Size of each FFT
int num_ffts = 1; // How many FFTs to do
cufftComplex *in_buf_h, *in_buf_d, *out_buf_d;
// Allocate buffers on host and device
in_buf_h = new cufftComplex[fft_sz*num_ffts];
cudaMalloc(&in_buf_d, fft_sz*num_ffts*sizeof(cufftComplex));
cudaMalloc(&out_buf_d, fft_sz*num_ffts*sizeof(cufftComplex));
cudaMemset(out_buf_d, 0, fft_sz*num_ffts*sizeof(cufftComplex));
// Fill input buffer with zeros and copy to device
memset(in_buf_h, 0, fft_sz*num_ffts*sizeof(cufftComplex));
cudaMemcpy(in_buf_d, in_buf_h, fft_sz*num_ffts*sizeof(cufftComplex), cudaMemcpyHostToDevice);
// Plan num_ffts of size fft_sz
cufftHandle plan;
cufftCreate(&plan);
cufftMakePlan1d(plan, fft_sz, CUFFT_C2C, num_ffts, &work_size);
// Execute the plan. We don't actually care about values.
cufftExecC2C(plan, in_buf_d, out_buf_d, CUFFT_FORWARD);
// Sync the device to flush the output
cudaDeviceSynchronize();
return 0;
}
$ g++ t1338.cpp -I/usr/local/cuda/include -L/usr/local/cuda/lib64 -lcudart -lcufft
$
Your include statements are probably OK as-is, but I have used a format that says "search on the standard path for this file" and then I identify an addition to the standard path with
-I/usr/local/cuda/include
However your compile command is definitely missing the necessary link apparatus. You need to specify where to find the libraries (the path) with -L and then indicate the specific libraries to include, which are both the CUDA runtime library (-lcudart) and also the CUFFT library (-lcufft):
-L/usr/local/cuda/lib64 -lcudart -lcufft
The CUDA toolkit normally gets installed with sample codes which will have sample Makefiles you can inspect, or just compile those projects to see typical compilation command usage.
As I mentioned, this source code is incomplete. It doesn't do anything useful. It is just to demonstrate proper compilation behavior. In particular, I've omitted proper error checking, which I recommend you include in your actual codes.
Depending on whether your install created a symbolic link or not, you may need to change the above paths to:
-I/usr/local/cuda-9.0/include
and
-L/usr/local/cuda-9.0/lib64 -lcudart -lcufft
I'm programming c++ in Borland c++ 5.02. I'm trying to run this code:
#include <stdio.h>
#include <pthread.h>
#define NUM 5
main()
{
pthread_t t1, t2; /* two threads */
void *print_msg(void *);
pthread_create(&t1, NULL, print_msg, (void *)"hello");
pthread_create(&t2, NULL, print_msg, (void *)"world\n");
pthread_join(t1, NULL);
pthread_join(t2, NULL);
}
But I get this error:
Info :Compiling C:\BC5\BIN\noname00.cpp
Error: noname00.cpp(2,2):Unable to open include file 'PTHREAD.H'
Error: noname00.cpp(8,15):Undefined symbol 'pthread_t'
Error: noname00.cpp(8,15):Statement missing ;
Error: noname00.cpp(12,18):Call to undefined function 'pthread_create'
I highlighted the main error which is caused by 'PTHREAD.H'. I checked the include folder for this file. It doesn't exist. How can I fix this problem?
Borland's C++ toolchain doesn't include a pthreads library, nor does the Windows SDK. You'll either need to use native Win32 thread APIs or get a 3rd party pthreads implementation for Windows.
Some options include:
winpthreads.h: http://locklessinc.com/articles/pthreads_on_windows/
pthreads-win32: https://www.sourceware.org/pthreads-win32/
I have no idea how well those things work with Borland C++ 5.x.
Another alternative is to use a toolchain that includes a pthreads implementation, such as TDM's MinGW toolchain:
http://tdm-gcc.tdragon.net/
your problem is #include <pthread.h>
you need either copy all the pthread related files (.h,.c,.cpp,.hpp,.lib,.obj)
into compiler include folder
or add include path to it in your project/compiler settings
or copy it locally to your project and change #include <pthread.h> to #include "pthread.h"
So compiler did not find the pthread.h header
so no datatype from it is known from compiler side (like pthread_t)
therefore the rest of the errors...
I am pretty new to linux and i wanted to try to make a small opengl
program just as a test. I'm using glfw and i made a very easy test:
#include <iostream>
#include <GL/glew.h>
#include <GLFW/glfw3.h>
using namespace std;
int main()
{
if (!glfwInit())
{
return -1;
}
GLFWwindow *window = glfwCreateWindow(800, 600, "Het werkt", NULL, NULL);
if (!window)
{
glfwTerminate();
}
glfwMakeContextCurrent(window);
while (!glfwWindowShouldClose(window))
{
glfwPollEvents();
glfwSwapBuffers(window);
}
}
Now if i try to run this in Code::Blocks itself, it runs fine, debug, release, it doesn't matter, it works. But when i try to execute it outside Code::Blocks, it goes wrong. If i double click the executable nothing happens, and if i ./ExecutableName in the terminal it gives me this error:
error while loading shared libraries: libglfw.so.3: cannot open shared object file: No such file or directory
All of the libs are in the same directory as the executable, so i don't get why it gives this error.
By the way i'm working on Linux Mint.
Thanks in advance for your help!
You should place those libraries in your $PATH. Issue a echo $PATH command and see if you can find the libraries in there (within those paths) - if not, you will have to put them in there someway. I'm not sure if you can just copy-paste the libraries in there, so probably you may want to search for them using your linux distribution's package management system. As you are using Linux Mint, maybe you could try searching with sudo aptitude search glfw and then try installing the corresponding packages.
I am trying to build a cocos2dx project for x86 android architecture but i get the following error when i try to compile it.
./obj/local/x86/curl.a(hostip.o):(.text.alarmfunc+0x21): undefined reference to `siglongjmp'
./obj/local/x86/curl.a(hostip.o): In function `Curl_resolv_timeout':
(.text.Curl_resolv_timeout+0x156): undefined reference to `sigsetjmp'
When i googled the error i found that it has been reported as issue 19851 in google code. They have not made any fixes yet but they had suggested to add a modified libc.so and sched.h file. I tried this and it did not work.
Can anyone tell me how to fix this.
Try adding this code to one of your .c or .cpp modules:
#if __i386 && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
#include <setjmp.h>
#ifdef __cplusplus
extern "C" {
void siglongjmp(jmp_buf env, int val);
int sigsetjmp(jmp_buf env, int savemask);
}
#endif
void siglongjmp(jmp_buf env, int val)
{
longjmp(env, val);
}
int sigsetjmp(jmp_buf env, int savemask)
{
return setjmp(env);
}
#endif
Fixed the issue by copying libc.so attached in response to issue 19851 to latest version of ndk. I was using ndkr8 and copying the libc.so file to ndkr8d fixed the issue.
Go to the Android NDK page & follow the download and installation instructions.
https://developer.android.com/tools/sdk/ndk/index.html
I'm on OSX, android-ndk-r10e-darwin-x86_64.bin fixed the error for my setup.
I am using Ubuntu-11.04 OS. i wrote a basic interactive kernel module mid.c
#include<linux/kernel.h>
#include<linux/module.h>
#include<linux/init.h>
static int __init insert(void)
{
pr_info(" The module is inserted into the kernel \n");
return 0;
}
static void __exit remove(void)
{
pr_info("the module is removed from kernel \n");
}
module_init(insert);
module_exit(remove);
i can compile the module by using the command
make -C /lib/modules/2.6.38-8-generic/build M=$(PWD) modules
but when i try to insert the module using the command
insmod mod.ko
an error occurs saying :
cannot insert mod.ko permission denied
you need to add a sudo before insmod