Last active
July 1, 2018 12:18
-
-
Save iwatake2222/efdf5d9c2f324fc6a5e146f17da937af to your computer and use it in GitHub Desktop.
ラズパイ用のC/C++開発環境をお手軽に構築する ref: https://qiita.com/take-iwiw/items/46119bb7d41c6030d34f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "host": "192.168.1.88", | |
| "port": 22, | |
| "username": "pi", | |
| "password": "rasp", | |
| "protocol": "sftp", | |
| "agent": null, | |
| "privateKeyPath": null, | |
| "passphrase": null, | |
| "passive": false, | |
| "interactiveAuth": false, | |
| "remotePath": "/home/pi/MyCProject", | |
| "uploadOnSave": true, | |
| "syncMode": "update", | |
| "watcher": { | |
| "files": false, | |
| "autoUpload": false, | |
| "autoDelete": false | |
| }, | |
| "ignore": [ | |
| "**/.vscode/**", | |
| "**/.git/**", | |
| "**/.DS_Store" | |
| ] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| void ppp() | |
| { | |
| printf("ppp\n"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void ppp(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include "aaa.h" | |
| #include "subA.h" | |
| #include "subB.h" | |
| int main() | |
| { | |
| printf("Hello World\n"); | |
| ppp(); | |
| printf("%d %d\n", subFunc1(), subFunc2()); | |
| printf("%d %d\n", subFunc3(), subFunc4()); | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| include makefile_config | |
| TARGET = a.out | |
| SRCS = main.cpp aaa.cpp | |
| SUBDIRS = subStaticModuleA subDynamicModuleB | |
| INCLUDES += -IsubStaticModuleA -IsubDynamicModuleB | |
| SUBS = subStaticModuleA/subModuleA.a | |
| LIBS += -L./ -lsubModuleB | |
| all: sub_target $(TARGET) | |
| $(TARGET): $(OBJS) $(SUBS) | |
| $(CC) $(LDFLAGS) -o $@ $(OBJS) $(SUBS) $(LIBS) | |
| .PHONY: sub_target | |
| sub_target: | |
| ifdef SUBDIRS | |
| $(foreach subdir,$(SUBDIRS),cd $(subdir) && $(MAKE) && cd ../ &&) cd ./ | |
| endif | |
| .PHONY: clean | |
| clean: | |
| $(DEL) *.o *.a *.exe *.dll *.so *.out | |
| ifdef SUBDIRS | |
| $(foreach subdir,$(SUBDIRS),cd $(subdir) && $(MAKE) clean && cd ../ &&) cd ./ | |
| endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## environment | |
| #PLATFORM = WIN_MINGW | |
| PLATFORM = LINUX | |
| BINARY = DEBUG | |
| #BINARY = RELEASE | |
| ifeq ($(PLATFORM), WIN_MINGW) | |
| # for win | |
| MAKE = mingw32-make | |
| #DEL = del | |
| DEL = rm -f | |
| CC = g++ | |
| AR = ar | |
| else | |
| # for linux | |
| MAKE = make | |
| DEL = rm -f | |
| CC = g++ | |
| AR = ar | |
| endif | |
| ifeq ($(BINARY), DEBUG) | |
| CFLAGS = -g3 -O0 -Wall | |
| else | |
| CFLAGS = -O3 -Wall | |
| endif | |
| LDFLAGS = | |
| LIBS = -lm | |
| OBJS = $(SRCS:.cpp=.o) | |
| #OBJS = *.o | |
| .c.o: | |
| $(CC) $(CFLAGS) $(INCLUDES) -c $< | |
| .cpp.o: | |
| $(CC) $(CFLAGS) $(INCLUDES) -c $< |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| include ../makefile_config | |
| TARGET = ../libsubModuleB.so | |
| SRCS = subB1.cpp subB2.cpp | |
| INCLUDES = | |
| SUBS = | |
| SUBDIRS = | |
| all: sub_target $(TARGET) | |
| $(TARGET): $(OBJS) $(SUBS) | |
| $(CC) $(LDFLAGS) -shared -fPIC -o $@ $(OBJS) $(SUBS) | |
| .PHONY: sub_target | |
| sub_target: | |
| ifdef SUBDIRS | |
| $(foreach subdir,$(SUBDIRS),cd $(subdir) && $(MAKE) && cd ../ &&) cd ./ | |
| endif | |
| .PHONY: clean | |
| clean: | |
| $(DEL) *.o *.a *.exe *.dll | |
| ifdef SUBDIRS | |
| $(foreach subdir,$(SUBDIRS),cd $(subdir) && $(MAKE) clean && cd ../ &&) cd ./ | |
| endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int subFunc3(); | |
| int subFunc4(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int subFunc3() | |
| { | |
| return 150; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int subFunc4() | |
| { | |
| return 64645; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| include ../makefile_config | |
| TARGET = subModuleA.a | |
| SRCS = subA1.cpp subA2.cpp | |
| INCLUDES = | |
| SUBS = | |
| SUBDIRS = | |
| all: sub_target $(TARGET) | |
| $(TARGET): $(OBJS) $(SUBS) | |
| $(AR) r $@ $(OBJS) $(SUBS) | |
| .PHONY: sub_target | |
| sub_target: | |
| ifdef SUBDIRS | |
| $(foreach subdir,$(SUBDIRS),cd $(subdir) && $(MAKE) && cd ../ &&) cd ./ | |
| endif | |
| .PHONY: clean | |
| clean: | |
| $(DEL) *.o *.a *.exe *.dll | |
| ifdef SUBDIRS | |
| $(foreach subdir,$(SUBDIRS),cd $(subdir) && $(MAKE) clean && cd ../ &&) cd ./ | |
| endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int subFunc1(); | |
| int subFunc2(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int subFunc1() | |
| { | |
| return 10; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int subFunc2() | |
| { | |
| return 20; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /ComplexCProject | |
| - main.cpp, aaa.cpp | |
| - makefile | |
| - makefile_config | |
| - subStaticModuleA/ | |
| - subA1.cpp, subA2.cpp | |
| - makefile | |
| - subDynamicModuleB/ | |
| - subB1.cpp, subB2.cpp | |
| - makefile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MyCProject/ | |
| - main.cpp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| HOST> ssh [email protected] | |
| PI> cd MyCProject | |
| PI> gcc -g3 main.cpp | |
| PI> ./a.out |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| HOST> ssh [email protected] | |
| PI> cd MyCProject | |
| PI> gdb ./a.out | |
| (gdb) b main | |
| (gdb) run | |
| (gdb) n | |
| (gdb) n |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| PI> cd | |
| PI> wget -P ~ git.io/.gdbinit | |
| PI> cd MyCProject | |
| PI> gdb ./a.out | |
| >>> b main | |
| >>> run | |
| >>> p i | |
| >>> p i = 9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| PI_1> tty # ターミナル1でターミナル名を確認 | |
| /dev/pts/1 | |
| PI_0> gdb ./a.out # ターミナル0でgdb起動 | |
| >>> dashboard -output /dev/pts/1 # 出力先を↑で確認したターミナルに切り替える | |
| >>> b main | |
| >>> run |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /ComplexCProject | |
| - main.cpp, aaa.cpp | |
| - makefile | |
| - makefile_config | |
| - subStaticModuleA/ | |
| - subA1.cpp, subA2.cpp | |
| - makefile | |
| - subDynamicModuleB/ | |
| - subB1.cpp, subB2.cpp | |
| - makefile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| HOST> ssh [email protected] | |
| PI> cd MyCProject | |
| PI> gdb ./a.out | |
| (gdb) b main | |
| (gdb) run | |
| (gdb) n | |
| (gdb) n |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| PI> cd | |
| PI> wget -P ~ git.io/.gdbinit | |
| PI> cd MyCProject | |
| PI> gdb ./a.out | |
| >>> b main | |
| >>> run | |
| >>> p i | |
| >>> p i = 9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| PI_1> tty # ターミナル1でターミナル名を確認 | |
| /dev/pts/1 | |
| PI_0> gdb ./a.out # ターミナル0でgdb起動 | |
| >>> dashboard -output /dev/pts/1 # 出力先を↑で確認したターミナルに切り替える | |
| >>> b main | |
| >>> run |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| int main() | |
| { | |
| printf("Hello World\n"); | |
| for(int i = 0; i < 10; i++) { | |
| printf("i = %d\n", i); | |
| } | |
| printf("Done\n"); | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| include ../makefile_config | |
| TARGET = ../libsubModuleB.so | |
| SRCS = subB1.cpp subB2.cpp | |
| INCLUDES = -I./ | |
| SUBS = | |
| SUBDIRS = | |
| all: sub_target $(TARGET) | |
| $(TARGET): $(OBJS) $(SUBS) | |
| $(CC) $(LDFLAGS) -shared -fPIC -o $@ $(OBJS) $(SUBS) | |
| .PHONY: sub_target | |
| sub_target: | |
| ifdef SUBDIRS | |
| $(foreach subdir,$(SUBDIRS),cd $(subdir) && $(MAKE) && cd ../ &&) cd ./ | |
| endif | |
| .PHONY: clean | |
| clean: | |
| $(DEL) *.o *.a *.exe *.dll | |
| ifdef SUBDIRS | |
| $(foreach subdir,$(SUBDIRS),cd $(subdir) && $(MAKE) clean && cd ../ &&) cd ./ | |
| endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| include ../makefile_config | |
| TARGET = subModuleA.a | |
| SRCS = subA1.cpp subA2.cpp | |
| INCLUDES = -I./ | |
| SUBS = | |
| SUBDIRS = | |
| all: sub_target $(TARGET) | |
| $(TARGET): $(OBJS) $(SUBS) | |
| $(AR) r $@ $(OBJS) $(SUBS) | |
| .PHONY: sub_target | |
| sub_target: | |
| ifdef SUBDIRS | |
| $(foreach subdir,$(SUBDIRS),cd $(subdir) && $(MAKE) && cd ../ &&) cd ./ | |
| endif | |
| .PHONY: clean | |
| clean: | |
| $(DEL) *.o *.a *.exe *.dll | |
| ifdef SUBDIRS | |
| $(foreach subdir,$(SUBDIRS),cd $(subdir) && $(MAKE) clean && cd ../ &&) cd ./ | |
| endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| include makefile_config | |
| TARGET = a.out | |
| SRCS = main.cpp aaa.cpp | |
| SUBDIRS = subStaticModuleA subDynamicModuleB | |
| INCLUDES += -I./ -IsubStaticModuleA -IsubDynamicModuleB | |
| SUBS = subStaticModuleA/subModuleA.a | |
| LIBS += -L./ -lsubModuleB | |
| all: sub_target $(TARGET) | |
| $(TARGET): $(OBJS) $(SUBS) | |
| $(CC) $(LDFLAGS) -o $@ $(OBJS) $(SUBS) $(LIBS) | |
| .PHONY: sub_target | |
| sub_target: | |
| ifdef SUBDIRS | |
| $(foreach subdir,$(SUBDIRS),cd $(subdir) && $(MAKE) && cd ../ &&) cd ./ | |
| endif | |
| .PHONY: clean | |
| clean: | |
| $(DEL) *.o *.a *.exe *.dll *.so *.out | |
| ifdef SUBDIRS | |
| $(foreach subdir,$(SUBDIRS),cd $(subdir) && $(MAKE) clean && cd ../ &&) cd ./ | |
| endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## environment | |
| #PLATFORM = WIN_MINGW | |
| PLATFORM = LINUX | |
| BINARY = DEBUG | |
| #BINARY = RELEASE | |
| ifeq ($(PLATFORM), WIN_MINGW) | |
| # for win | |
| MAKE = mingw32-make | |
| #DEL = del | |
| DEL = rm -f | |
| CC = g++ | |
| AR = ar | |
| else | |
| # for linux | |
| MAKE = make | |
| DEL = rm -f | |
| CC = g++ | |
| AR = ar | |
| endif | |
| ifeq ($(BINARY), DEBUG) | |
| CFLAGS = -g3 -O0 -Wall | |
| else | |
| CFLAGS = -O3 -Wall | |
| endif | |
| LDFLAGS = | |
| LIBS = -lm | |
| OBJS = $(SRCS:.cpp=.o) | |
| #OBJS = *.o | |
| .c.o: | |
| $(CC) $(CFLAGS) $(INCLUDES) -c $< | |
| .cpp.o: | |
| $(CC) $(CFLAGS) $(INCLUDES) -c $< |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| int main() | |
| { | |
| printf("Hello World\n"); | |
| for(int i = 0; i < 10; i++) { | |
| printf("i = %d\n", i); | |
| } | |
| printf("Done\n"); | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MyCProject/ | |
| - main.cpp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "host": "192.168.1.88", | |
| "port": 22, | |
| "username": "pi", | |
| "password": "rasp", | |
| "protocol": "sftp", | |
| "agent": null, | |
| "privateKeyPath": null, | |
| "passphrase": null, | |
| "passive": false, | |
| "interactiveAuth": false, | |
| "remotePath": "/home/pi/MyCProject", | |
| "uploadOnSave": true, | |
| "syncMode": "update", | |
| "watcher": { | |
| "files": false, | |
| "autoUpload": false, | |
| "autoDelete": false | |
| }, | |
| "ignore": [ | |
| "**/.vscode/**", | |
| "**/.git/**", | |
| "**/.DS_Store" | |
| ] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| HOST> ssh [email protected] | |
| PI> cd MyCProject | |
| PI> gcc -g3 main.cpp | |
| PI> ./a.out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment