Ubuntu under C,C++,OPENCV cuda programming __linux

Source: Internet
Author: User
My first Ubuntu under the C program.

C language
1. First confirm that you have the GCC compiler

in the terminal input GCC--version view your GCC version. As shown, if there is no error occurs, it is installed


2. Create a new file of. C with a terminal

Type vim hello.cin the terminal (file name is optional, but you need to use. C as the extension).
3. After the creation press I enter the edit mode to enter the following code, then ESC exit screenwriter mode, in English state input: Wq (don't forget the colon) (for VIM word processing do not understand classmate, please see this blog Ubuntu below VI use base)


4. After compiling exit vim, type gcc hello.c-o Helloand enter to generate an executable named Hello.

5. Run

Run the executable file and type sudo./hello(note./not less).

If you want to write C + +, you need to create a. cpp file and use a g++ compiler, which is later.


2.CUDA Language

Use VI to create. cu files, enter programs, save exits.

Compile NVCC filename.cu-o filename (with an executable filename after-O).

Execute sudo./filename

3.OPENCV

New Opencvtest.cpp

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace CV;

int main ()
{
Mat src = imread ("test.jpg", 1);
Imshow ("src", SRC);
Waitkey (0);
return 0;
}


(Note that this is not a single quote, the key to the left of keyboard 1,--cflags and--libs preceded by a space ")

g++ opencvtest.cpp-o opencvtest ' pkg-config--cflags--libs opencv ' last OpenCV lowercase)


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.