新建一个test.cpp
#include<iostream>
using namespace std;
int main()
{
int a=11;
cout<<a<<endl;
}
1.打开终端,进入该文件所在位置
cd /.../
2.使用g++编译生成可执行文件
g++ test.cpp -o test
3.执行可执行文件
./test
实验结果

墨衍会员
·
AI 创作全网分发
墨衍智能分发
本文由作者通过墨衍一键同步至各平台
1分发平台
2.2k累计阅读
2.3k平均单平台
已同步平台
优快云
微信公众号
微博
知乎
掘金
百家号
博客园
抖音
小红书
你的文章也可以这样分发
墨衍会员 ¥399起/年,写一次发全网
我也要 →
码龄10年
新建一个test.cpp
#include<iostream>
using namespace std;
int main()
{
int a=11;
cout<<a<<endl;
}
1.打开终端,进入该文件所在位置
cd /.../
2.使用g++编译生成可执行文件
g++ test.cpp -o test
3.执行可执行文件
./test
实验结果

保姆级教程:在Ubuntu 20.04上搞定pybind11编译与Python调用C++库
本文提供了一份详细的Ubuntu 20.04环境下pybind11编译与Python调用C++库的教程。从环境准备、pybind11安装策略到实战验证,涵盖了常见问题的解决方案和高级配置技巧,帮助开发者高效实现C++与Python的无缝交互。
Ubuntu下C++代码调用可执行文件。
例如:已经存在一个编译好的c++可执行文件: 简单代码(第一个可执行文件) vim hello.cpp #include <iostream> using namespace std; int main(){ cout<<"Ubuntu调用C++可执行文件成功"<<endl; return 0; } 编译成可执行文件 g++ -...
Ubuntu 系统安装 VS Code 并配置 C++ 环境
详细介绍了如何在Ubuntu上使用VS Code配置C++开发环境,包括安装必要的工具、设置编译器和调试器,并演示了如何创建和运行C++项目。
Ubuntu下编译运行C,C++
方法二:保存好c++文件后接下来就是编译成可执行文件,-o后面的hello就是可执行的文件名(可随意起一个filename)运行下面的命令,以指定编译出的文件名称。,touch是建立文件的命令,.c/.cpp的后缀表示文件的类型。首先,我们先建立一个文件夹或者打开我们的终端系统,在终端系统中建立并打开文件夹;:如果你是已经新建立了文件夹,要在文件夹在建立C/C++文件,必须要在该文件夹内右键鼠标进入终端。第二种编译运行下面的命令以执行编译后的文件,其中==“./”==是运行可执行文件的命令。
ubuntu18安装yaml-cpp
yaml-cppBoostyaml-cpp Boost 安装yaml-cpp依赖于boost库,确保Boost library已经存在,否则会报错。(yaml-cpp 0.6.0 has been released! This release requires C++11, and no longer depends on Boost.) 安装方法 使用命令安装 sudo apt-get install libboost-dev 文件安装 boost官网下载 解压并进入文件夹tar -zxvf
Obsidian从零搭建:可验证、可回溯、可演进的知识库工具链
个人知识库不是开箱即用的软件,而是基于Markdown内核构建的可演进系统。其核心原理在于分离‘稳定内核’与‘可插拔扩展’:Obsidian原生支持双链、嵌入、Frontmatter等基础能力,构成不可降级的知识骨架;而Dataview、Templater等插件则作为可验证、可回溯的增强层,需通过三问验证(解决痛点?有原生替代?失效可降级?)方可引入。这种设计赋予知识库技术价值——抗版本升级、跨平台兼容、离线可用,并支撑技术文档管理、项目复盘、读书笔记等真实场景。当面对computer use插件不可用或h
C++基础——Ubuntu下编写C++环境配置总结(C++基本简介、Ubuntu环境配置、编写简单C++例程)
本次博文内容主要介绍在 Ubuntu 在终端窗口下使用 vi/vim 编辑一个 C++源文件,通过编写最简单的示例“Hello,World!”。这个一看是很简单的,只要有点Linux基础就行了(如何使用Vim或Vi编辑器、如何在Linux下编译等),之前博主在《从0到1学习嵌入式Linux开发实战》中总结了Liunx系统编程,里面的内容足以解决这个问题。 博主后续打算深入下嵌入式QT开发,内容将会在《QT开发实战》中继续,QT开发中使用的语言是C++,所以博主新建立了此
PCIe链路均衡实战:从Preset调节到系数优化的完整指南(附Synopsy IP案例)
本文深入解析PCIe链路均衡技术,从Preset调节到系数优化的全流程实战指南,特别针对PCIe 3.0/4.0中的Recovery.Equalization状态进行详细说明。通过Synopsy IP案例,展示如何应对高速信号完整性挑战,优化前向反馈均衡(FFE)机制,提升系统性能。
在Ubuntu中编译C++代码(从安装虚拟机到完成编译)
从VMware下载开始,一步一步实现在Ubuntu中编译c++。主要内容包括虚拟机的下载,镜像文件的下载,虚拟机的创建,cmake的安装。
基于FPGA的PCIe核系列:FPGA root模式生成工程例子分析(1)
一、 PCIE系统架构 1.1 PCIE分层结构 PCIE结构 1.2 TLP包 四种TLP类型。 Memory (内存空间操作) IO (IO空间操作) Configuration (配置操作) Message (信息操作) 四种类型TLP,如果有需要响应,称为Non-Posted TLP,如果没有需要响应,称为Posted TLP。 TLP包类型 1.2.1 TLP结构 TLP数据格式 1.2.2 Header各个字段的含义 Header格式 ...
保姆级教程:在RK3588开发板上编译带MPP硬件加速的FFmpeg(含完整依赖库配置)
本文提供在RK3588开发板上编译支持MPP硬件加速的FFmpeg的详细教程,涵盖交叉编译环境搭建、MPP框架及依赖库配置,最终实现4K视频硬件编解码性能优化。通过实战步骤和性能对比,展示如何充分发挥RK3588的硬件加速能力。
Ubuntu中使用命令运行C/C++程序
在ubuntu环境下对C/C++进行编译首先保证ubuntu系统中包含编译工具(g++/gcc)和编辑工具(vim),C语言和C++对应的编译器分别为gcc,g++。 如果缺少上述的相关应用,则需要先执行如下命令: sudo apt-get install build-essential sudo apt install vim sudo apt-get install gcc sudo apt-get install g++ C语言的运行 首先写一段简单的hello world程序,命名为hello.c
C#与西门子PLC S7-1500 S7协议PLC读写数据
/获取对应长度的字符串。//将val字符串转换为字符数组。//String写入。//String读取。//PLC类型 IP地址 机架号 槽号。1.类库使用S7netplus。
Ubuntu20.04下Px4使用UORB发布消息
文件位置如图,在PX4-Autopilot/msg文件夹下,笔者创建的文件名为gps_msg.msggps_msg.msg内容如下uint64 timestamp # 时间戳同时,在CMakeLists.txt中添加gps_msg.msg。
知识推理——TransE(知识表示、知识嵌入)
知识图谱嵌入/表示方法 TransE
突破Cloudflare 5秒盾:TLS指纹伪装+Playwright行为模拟,爬虫存活率从35%提至78%
TLS指纹精准识别:Cloudflare会解析客户端的TLS Client Hello包(如SSL版本、密码套件、扩展字段),Python的requests/urllib库的TLS指纹是“黑名单级”,请求一出即被拦截;行为特征检测:静态的浏览器伪装(如User-Agent)已失效,Cloudflare会监控页面加载后的行为(是否有鼠标移动、滚动、点击,行为是否机械);JS环境深度验证:通过WebGL、Canvas、字体渲染、Navigator属性生成浏览器指纹,无头浏览器的默认配置会被瞬间识别;
假如ubuntu直接用cmake命令编译android app会怎么样
因为从CPP代码转换为二进制代码,在不同平台上面是有不同二进制代码的,所以一定会发生很多莫名其妙的事情。就像我现在出现的情况几乎搜索不到答案了。如果我在这个ubuntu平台编译需要运行在android平台的软件,那么需要使用交叉编译的方式。首先需要知道一个概念:交叉编译。
【OpenClaw从入门到精通】第73篇:30天OpenClaw实战挑战——从零搭建个人数字助理(Day15-21)万字超详细高阶实战版
经过前两周的基础部署与功能搭建,你已拥有可自动化干活的AI助理与数字员工团队,但距离“高阶精通”仍有差距。本文聚焦第三周(Day15-21)核心实战,围绕安全审计、语音能力接入、Token成本控制、Agent Loop优化、One-Liner指令五大核心模块,结合真实落地案例与踩坑经验,提供超详细实操指南。通过本文,你将掌握生产级安全加固方案、语音交互全流程配置、低成本高性价比使用策略、Agent自主闭环优化技巧,以及一句话搞定复杂任务的高效指令用法,同时完成中期复盘与最后九天冲刺规划
ubuntu sdl2 cmake安装使用
set(EXECUTABLE_OUTPUT_PATH${PROJECT_SOURCE_DIR}/bin)#设置编译后的程序存放位置。SET(CMAKE_BUILD_TYPE"Debug")#定义编译类型。2.编写cmakelists.txt。3.运行C++示例代码。
Camera2Demo
在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作
pscad IEEE标准系统搭建说明
pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。
ubuntu14.04 gedit配置
ubuntu14.04系统下,快捷键编译gedit生成的c++和c和java文件设置 gedit的配置 tool->tool manager #!/bin/sh fullname=$GEDIT_CURRENT_DOCUMENT_NAME name=`echo $fullname | cut -d. -f1` suffix=`echo $fullname | cut -
深度学习工具包 DeepLearningToolbox
深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[](https://bitdeli.com/free "Bitdeli Badge")
Ubuntu16.04 安装VSCode 并配置C/C++ Debug
1.安装: sudo add-apt-repository ppa:ubuntu-desktop/ubuntu-make sudo apt-get update sudo apt-get install ubuntu-make sudo umake ide visual-studio-code 按提示安装就OK了。 安装完成之后,在搜索框可以找到VSCode的图标。 但是不管怎么点...
RU DOS版、EFI版32bit/64bit BIOS常用工具
DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。
在ubuntu创建、保存、运行c++文件
自从上了 C++ 编程课后,我的三观塌了,因为: Only your friends can touch your private, neither your parents nor your children. 打开终端,输入以下命令,创建一个空的.cpp文件: ~$ touch main.cpp 在gedit中打开这个文件(gedit 貌似是ubuntu自带的编辑器): ...
C++类型转换之reinterpret_cast
reinterpret_cast使用
Ubuntu 运行 C++ 文件
编写CMakeLists.txt。
Ubuntu 中使用终端编译并运行.c和.cpp文件
1、.c文件的编译与运行 (1).c文件hello.c代码如下: #include<stdio.h> int main() { printf("Hello world !\n"); return 0; } 在当前路径下编译.c文件: gcc -o hello hello.c 编译完成后可以看到在和...
Ubuntu14.04下C++程序编辑、编译、运行入门篇
初次接触Ubuntu,一脑子的糊涂,更别提如何在Ubuntu下编译运行C++程序了,经过查资料,下面是自己在Ubuntu下写的第一个C++程序,仅供初学者参考,也为自己的入门学习梳理下思路。 一、编译单个cpp文件 1、输入组合键“Ctrl+Alt+t”调出终端; 2、需要在当前目录下创建一个.cpp文件,这里命名为first.cpp,通过命令“touch first.cpp”就可以直接创建...
2847

被折叠的 条评论
为什么被折叠?



