Skip to content

Commit 747ff45

Browse files
Add Linux C++ Hello World project
1 parent 7bf4834 commit 747ff45

File tree

7 files changed

+648
-0
lines changed

7 files changed

+648
-0
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ bld/
3030
[Oo]bj/
3131
[Ll]og/
3232
[Ll]ogs/
33+
out/
3334

3435
# Visual Studio 2015/2017 cache/options directory
3536
.vs/

Diff for: src/LinuxClangHelloWorld/.vscode/launch.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "(gdb) Launch",
5+
"type": "cppdbg",
6+
"request": "launch",
7+
"preLaunchTask": "build",
8+
"program": "${workspaceRoot}/out/Linux/bin/x64.Debug/HelloWorld",
9+
"args": [],
10+
"stopAtEntry": false,
11+
"cwd": "${fileDirname}",
12+
"environment": [],
13+
"externalConsole": false,
14+
"MIMode": "gdb",
15+
"setupCommands": [
16+
{
17+
"description": "Enable pretty-printing for gdb",
18+
"text": "-enable-pretty-printing",
19+
"ignoreFailures": true
20+
},
21+
{
22+
"description": "Set Disassembly Flavor to Intel",
23+
"text": "-gdb-set disassembly-flavor intel",
24+
"ignoreFailures": true
25+
}
26+
]
27+
}
28+
]
29+
}

Diff for: src/LinuxClangHelloWorld/.vscode/tasks.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=733558
3+
// for the documentation about the tasks.json format
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"label": "build",
8+
"type": "shell",
9+
"command": "${workspaceRoot}/build.sh",
10+
"problemMatcher": "$msCompile"
11+
}
12+
]
13+
}

Diff for: src/LinuxClangHelloWorld/CMakeLists.txt

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
cmake_minimum_required(VERSION 2.8.12)
2+
3+
project(hello_world)
4+
5+
if (APPLE)
6+
set(CMAKE_INSTALL_RPATH "@executable_path")
7+
else(UNIX)
8+
set(CMAKE_INSTALL_RPATH "\$ORIGIN")
9+
endif()
10+
11+
add_compile_options(-std=c++11)
12+
add_executable(HelloWorld HelloWorld.cpp)
13+
set_property(TARGET HelloWorld APPEND_STRING PROPERTY COMPILE_FLAGS "-fvisibility=hidden")
14+
15+
target_link_libraries(HelloWorld stdc++)
16+
# add_install(TARGETS HelloWorld RUNTIME)
17+
install(TARGETS HelloWorld RUNTIME
18+
DESTINATION .)

Diff for: src/LinuxClangHelloWorld/HelloWorld.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <iostream>
2+
#include <stdio.h>
3+
4+
int main(int argc, char* argv[])
5+
{
6+
for (int c = 0; c < argc; c++)
7+
{
8+
printf("argv[%d] = '%s'\n", c, argv[c]);
9+
}
10+
printf("argv[%d] = %p\n", argc, argv[argc]);
11+
12+
std::cout << "Hello World" << std::endl;
13+
}

Diff for: src/LinuxClangHelloWorld/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Summary
2+
3+
This is an example project that uses CMake and Clang to build on Linux.

0 commit comments

Comments
 (0)