Installing Code::Blocks from source on Linux

Linux下 Code::Blocks配置 最近由于课程设计和项目要求等原因将操作系统转移到Ubuntu了,发现在Linux下Code::Blocks简直是C/C++编程的神器,于是乎想记下器安装过程 1.用命令行安装是最为方便的,当然你也可以去官网下载,不过注意要下载带编译器的,不然会被折磨- - 2.安装完之后安装G++ 3.打开codeblocks,建立c项目,出现了我们熟知的helloworld程序 4. 阅读详情

From CodeBlocks

Jump to: navigation, search

These are instructions on how to build Code::Blocks under Linux. I 've ran and verified this procedure to work under SuSE 9.2 and Fedora Core 3. These instructions should work for all Linux distros, as we 'll be installing from sources.

Contents

[hide]
[ edit]

Prerequisites

In order to sucesfully compile Code::Blocks, the wxWidgets (wxGTK-2.6.1 or later) cross-platform UI library must be installed. In this document, it is not assumed that it is already installed in your system and instructions are given on how to download, build and install it. What is not covered here, is the wxWidgets prerequisites. The most important being GTK2, of course! Let me stress it here, while it's early: GTK2 is required, not GTK1, for Code::Blocks to be operational.

You do not need to Compile wxWidgets if your distribution has wxGTK 2.6 and wxGTK 2.6-dev package available. A quick search for "wxGTK" through your respective package manager should show bring up the needed packages. After you have installed successfully you can moving on the the Installing Code::Blocks portion. If you are using Ubuntu and have installed the wxGTK package, you must also have the dev version as well as the "wx-common" package in order to successfully compile Code::Blocks.

All the instructions below, assume an existing directory named ~/devel. If you 'll be using a different one, adjust the path to match. As a first step create this directory:

mkdir ~/devel
[ edit]

wxGTK installation

[ edit]
Getting wxGTK

Visit the wxWidgets web site. Click the "Download" button at the top of the page. Under wxWidgets 2.6.3 downloads, select wxGTK. Save the file in ~/devel.

wxWidgets project has released two patches for 2.6.3 release. Click the "Patches" in the left side of the page. Download the Patch 2, either in zip or tar.gz format. Save the file in ~/devel

[ edit]
Uncompressing the wxGTK sources

After the download finishes, switch to ~/devel:

cd ~/devel

Now, untar the wxGTK sources:

tar zxf wxGTK-2.6.3.tar.gz

Move the patch to the wxGTK directory

mv wxWidgets-2.6.3-Patch-2.tar.gz wxGTK-2.6.3

or

mv wxWidgets-2.6.3-Patch-2.zip wxGTK-2.6.3

Switch to the wxGTK directory

cd wxGTK-2.6.3

Extract the patch

tar zxf wxWidgets-2.6.3-Patch-2.tar.gz

or

unzip -fo wxWidgets-2.6.3-Patch-2.zip

Remove the patch file

rm wxWidgets-2.6.3-Patch-2.tar.gz

or

rm wxWidgets-2.6.3-Patch-2.zip
[ edit]
wxWidgets build

Here we will create a seperate build directory instead of building from the src directory, so that we can easily rebuild with different options (unicode / ansi, monolithic / many libs, etc).

The documentation says the default is for gtk2 to use unicode and wx > 2.5 to build as a monolithic library. This doesn't appear to be the case, so these flags are passed to configure.

mkdir build_gtk2_shared_monolithic_unicode
cd build_gtk2_shared_monolithic_unicode
../configure --prefix=/opt/wx/2.6 /
--enable-xrc /
--enable-monolithic /
--enable-unicode
make
make -C contrib/src/stc
su
make install
make -C contrib/src/stc install
exit

(Note: it's not necessary to make or install stc if you're compiling cvs HEAD or Code::Blocks newer than RC1)

Add /opt/wx/2.6/bin to the PATH (if you're shell is bash then edit /etc/profile or ~/.bash_profile) (On Suse 10.1 edit /etc/profile.local, it will only be available after a new login). an example PATH

export PATH=/usr/bin:/opt/wx/2.6/bin:$PATH

Note: On Ubuntu Hoary it was necessary to check "Run command as login shell" in the gnome-terminal profile-settings, otherwise the PATH changes are not available in a gnome-terminal window.

add /opt/wx/2.6/lib to /etc/ld.so.conf (nano /etc/ld.so.conf) then run:

ldconfig
source /etc/profile

That's it. Now the linker will look in /opt/wx/2.6/lib for wx libraries and you will have a monolithic shared library unicode build.

To check that things are working, type:

wx-config --prefix

which should give you /opt/wx/2.6

wx-config --libs

which should have at least

-L/opt/wx/2.6/lib -lwx_gtk2-2.6

but can contain other flags as well.

which wx-config

should return /opt/wx/2.6/bin/wx-config

[ edit]

Code::Blocks installation

[ edit]
Downloading Code::Blocks

You can get Code::Blocks source code in one of two ways:

  • Download the latest source package, or
  • Get the latest sources from the SVN repository.

Both methods, are described below.


[ edit]
Downloading the latest source package

Go to the Code::Blocks web site and download the latest source package. This would be the " Code::Blocks IDE version 1.0rc2 source code (tarball)" codeblocks-1.0rc2.tar.gz. Save this file in ~/devel and then untar it:

cd ~/devel
tar zxf codeblocks-1.0rc2.tar.gz

This will create the directory ~/devel/codeblocks-1.0rc2. Change to the source code directory, by issuing the following command:

cd codeblocks-1.0rc2
[ edit]
Getting the latest sources from SVN

IMPORTANT NOTICE: The Sourceforge CVS is no longer used although it still exists,

but we can get it from this SVN server:

Repository url: svn://svn.berlios.de/codeblocks/trunk

Sample command line: svn checkout svn://svn.berlios.de/codeblocks/trunk

Enter your development directory:

cd ~/devel

Then checkout the source using one of these methods.

This will create the directory trunk. Change to the source code directory, by issuing the following command:

cd trunk
[ edit]
Building Code::Blocks RC2 and SVN

If you are a Gentoo user, please see Compiling_Code::Blocks_in_Gentoo.

Before beginning, it is often a good idea to check you have recent versions of autoconf and automake - repositories versions are not always recent enough.

If you're compiling the svn trunk versions of CodeBlocks (or future versions) then the unix build has switched to autotools. So first build wxWidgets as described above and then build CodeBlocks as follows:

./bootstrap

This sets up the configure script and it's dependencies. It only needs to be run once (after downloading the source from svn). If you get errors like:

aclocal:configure.in:61: warning: macro `AM_OPTIONS_WXCONFIG' not found in library

Then aclocal is having trouble finding the wxWidgets .m4 files. You can do one of two things: To just get bootstrap to find the path this time do:

export ACLOCAL_FLAGS="-I `wx-config --prefix`/share/aclocal"

To change the aclocal search path more permanently do:

echo `wx-config --prefix`/share/aclocal >> /usr/share/aclocal/dirlist

Then aclocal will also search somewhere like /opt/wx/2.6/share/aclocal

Note for Ubuntu users: The above is not the correct way to fix the AM_* errors. Rather, you only need to install the package named "wx-common" (Universe repository).

If you get something like

The usual way to define `LIBTOOL' is to add `AC_PROG_LIBTOOL'

it can be solved by something like: (adapt path, use `wx-config --prefix` is necessary)

ACLOCAL_FLAGS="-I /usr/share/aclocal" ./bootstrap

(*Note// If you run ./bootstrap and get errors like:

: bad interpreter: File not found

then there exists a problem with DOS line-endings. i had this error after i tried to build a codeblocks from sources which were checked out with cvs on a windows machine. After i checked out a fresh copy of codeblocks from cvs under Ubuntu linux (see above topic: Downloading the latest source package fom SVN), all errors were gone. //tiwag 051008*)
Or, instead of downloading from SVN, you might consider using the little command line tool dos2unix, which normally comes with most distributions. //lizzarddude060103
If configure aborts with some unspecific error message(".infig.status: error: cannot find input file: Makefile"), you might consider also running

dos2unix bootstrap acinclude.m4 codeblocks.pc.in configure.in Makefile.am

before running bootstrap

Once you've run the bootstrap script, installing is as simple as:

./configure
make
make install

If you have multiple versions of wxWidgets installed or kept them inplace, you can use ./configure --with-wx-config=/path/to/wx-config

To uninstall you can later run:

make uninstall

If you want to recompile everything, first run:

make clean
make distclean
make clean-bin
make clean-zipfiles

and then follow the above sequence for installing.

By default, CodeBlocks will install to /usr/local. If you want it in its own tree (so you can have multiple versions of CodeBlocks, each in its own subdirectory of /opt) replace the above ./configure command with:

./configure --prefix=/opt/codeblocks-svn

or similar. Then you can later install a different build like:

./configure --prefix=/opt/codeblocks2-svn

followed by 'make && make install' as usual.

By default, CodeBlocks will not compile the contributed plugins from SVN. If you want to compile / install them too, replace the above ./configure command with:

./configure --enable-contrib

followed by 'make && make install' as usual.

To see a list of other options available for configuring the build of CodeBlocks do:

./configure --help

To compile under gentoo, use

./configure --with-wx-config=wx-config-2.6
[ edit]
Building Code::Blocks RC1 and former

To build Code::Blocks all you have to do now is type:

make -f Makefile.unix

This will build everything: the application and the plugins. The final step is to update the working environment for your system:

make -f Makefile.unix update

The following notes about converting the line endings does not apply to the CVS Version! The "update" script included there works just fine.

Important note: Don't run that final make yet! The "update" script seems to be using Dos character encoding, which will result in its failure to run on Linux. To fix this, use dos2unix:

To install it in Gentoo, do:

# emerge -av dos2unix

In Debian and Ubuntu, do (as root, or using sudo etc.):

# apt-get install sysutils

This will install dos2unix. Now we are ready to convert the script.

# dos2unix -n update update.unix
# chmod +x update.unix
# ./update.unix

The first line converts the script character encoding, the second makes it executable and the third runs it. This trick is from a forum post by ilkapo.

OK. Now that the update script is converted to unix format, you can run the final make:

make -f Makefile.unix update

If everything's gone well, congratulations! You should be able to launch Code::Blocks by running the generated run.sh script in the output subdir:

output/run.sh

This script can be ran from anywhere in your system so, yes, you can make a shortcut to it on your desktop ;)

Enjoy!

Personal tools
Navigation
Tips:
In ubuntu, we can install wx* packages by Synaptic Package manager. Then compile and install CodeBlocks. 
Fedora Linux 下安装配置C开发环境Code::Blocks 阅读详情

相关推荐

NOI Linux 2.0下Code::Blocks配置与调试实战指南

集成开发环境(IDE)是程序员进行软件开发的核心工具,它通过整合代码编辑器、编译器、调试器等组件,极大提升了编码效率与项目管理能力。其工作原理在于提供统一的图形化界面,管理项目文件结构,并调用底层工具链完成代码的编译、链接与执行。在算法竞赛与C/C++教学场景中,一款轻量、高效且对标准支持良好的IDE尤为重要,它能帮助学习者将精力聚焦于算法逻辑本身,而非环境配置。Code::Blocks作为一款免费、开源、跨平台的C/C++ IDE,凭借其快速启动和高度可定制性,成为NOI Linux 2.0官方竞赛环境下

weixin_34006965的博客 425

code::blocks 在linux下的安装 全过程

渣渣要准备acm省赛了,比赛要求环境是linux,所以要临时抱佛脚了,先提前适应一下。 话说真的是安了2个小时啊,当跑出来“hello world”的时候真是想哭啊。。。 其实很多方法都可以安装,重要的是有的时候吧,你安装的对,但是她就是跑不出来。。 汇总了几种网上的方法,都是可以的。(亲试,哭~) 一:(来自网址 http://www.2cto.com/os/201510/44671

秦楚 2万+

Code::Blocks+MinGW教学环境配置与编译原理实践指南

C语言教学环境的核心需求是轻量、确定、透明——这正是Code::Blocks与MinGW组合不可替代的技术逻辑。作为面向初学者的编程教具,它不隐藏编译四阶段(预处理、编译、汇编、链接),不抽象工具链路径,也不绑架项目结构,使学生能直观理解gcc调用机制、GDB内存调试原理及UTF-8中文编码全流程。其开箱即用的MinGW集成包规避了VS Code等现代IDE在c_cpp_properties.json配置、PATH环境变量、IntelliSense索引等方面的认知过载,真正将学习焦点回归指针、内存布局与函数

weixin_30729609的博客 426

redhat7.1 ntfs 挂载

最近给redhat7.1挂载ntfs文件系统时失败了好几次,提示是没有安装C贬义环境,然后安装了gcc,就成功挂载了,下面是详细步骤[root@foundation59 Desktop]# fdisk -l ###查看所有磁盘信息Disk /dev/sdb: 750.2 GB, 750156374016 bytes, 1465149168 sectorsUnits = se...

weixin_34376562的博客 833

Windows 10 C语言环境搭建:Visual Studio、Code::Blocks与MinGW方案全解析

C语言作为编程的基石,其开发环境的搭建是学习与实践的第一步。在Windows平台上,由于系统生态的复杂性,环境配置常成为初学者的首要挑战。其核心原理在于编译器、链接器与系统库的协同工作,将源代码转换为可执行程序。掌握环境搭建不仅能提升开发效率,更是理解软件构建过程的关键。对于Windows用户,主流的C语言开发方案主要围绕集成开发环境与工具链的选择展开,这直接影响到学习曲线、调试体验与项目可移植性。本文聚焦于Visual Studio、Code::Blocks和MinGW这三种主流方案,深入剖析各自的安装流

weixin_30915951的博客 550

Code::Blocks缺失C++11/14/17编译选项?手把手教你配置MinGW-w64编译器

在C++开发中,编译器是将源代码转换为可执行程序的核心工具,其版本和配置直接决定了支持的C++语言标准(如C++11、C++14、C++17)。现代C++标准引入了自动类型推导、Lambda表达式、智能指针等关键特性,极大地提升了开发效率和代码安全性。对于使用Code::Blocks这类轻量级IDE的开发者而言,IDE本身不负责编译,其功能菜单(如C++标准选项)是动态读取并展示底层编译器(如GCC、MSVC、Clang)能力的结果。因此,当遇到IDE中缺失现代C++编译选项时,其技术根源通常指向编译器环境

weixin_30797199的博客 368

Windows和Linux平台配置Code::Blocks + wxWidgets的区别

Search directories > Compiler: 添加 $(wx.include) 和 $(wx.include)\msvc(若需要)。¡lib: $(base)\lib\gcc_dll(动态库)或 $(base)\lib\gcc_lib(静态库)按照向导填写项目名称和路径,选择 ​wxWidgets 3.2.x​(根据实际版本)。打开 Code::Blocks,选择 ​File > New > Project。选择 ​wxWidgets project,点击 ​Go。

Flywithdawn的博客 717

Code::Blocks+MinGW:C/C++教学环境配置与编译原理实践指南

C/C++编程入门的核心在于理解编译过程与工具链协同机制,而非仅掌握语法。Code::Blocks作为轻量级IDE,其价值源于对GCC编译流程的透明暴露——从预处理、编译、汇编到链接,每一步都可在Build Log中直观验证,天然契合《编译原理》基础教学需求。结合MinGW-w64工具链,它提供开箱即用的Windows本地编译能力,规避VS Code等现代IDE因环境配置复杂导致的‘头文件找不到’‘调试器无法附加’等高频故障。该组合特别适用于高校机房批量部署、算法实验、指针与内存可视化教学等强实践场景,是连

weixin_33863087的博客 340

Installing_Code::Blocks_from_source_on_Linux

http://wiki.codeblocks.org/index.php?title=Installing_Code::Blocks_from_source_on_Linux apt-get install build-essential apt-get install vim ls /usr/lib/libwx_gtk* apt-get install libwxgtk2

drbinzhao的专栏 1426

Code::Blocks-20.03深度解析:轻量级C/C++ IDE的设计哲学与实战指南

集成开发环境(IDE)是程序员提升开发效率的核心工具,它通过整合代码编辑、编译、调试等功能,简化了软件开发流程。其工作原理在于为特定的编程语言和工具链提供统一的操作界面和项目管理。对于C/C++开发而言,一个优秀的IDE能显著降低环境配置复杂度,让开发者更专注于算法和逻辑实现。Code::Blocks作为一款经典的开源跨平台IDE,其价值在于贯彻了“以编译器为中心”和“插件化架构”的设计理念,在保持核心轻量化的同时,提供了高度的可定制性和环境可控性。这使得它在教学、快速原型开发以及对编译环境有纯净要求的场景

weixin_34074740的博客 435

Code::Blocks-20.03:轻量、跨平台C/C++ IDE的配置、调试与实战指南

集成开发环境(IDE)是程序员提升开发效率的核心工具,它通过整合代码编辑、编译、调试等功能,简化了软件开发的复杂性。其工作原理在于提供一个统一的图形化界面,管理项目文件、调用编译器工具链、并与调试器交互。对于C/C++开发而言,一个优秀的IDE能显著降低环境配置门槛,让开发者更专注于代码逻辑本身。Code::Blocks作为一款开源、跨平台的C/C++ IDE,其价值在于提供了高度可配置和模块化的轻量级解决方案,尤其适合教学、嵌入式开发及希望深入理解构建过程的学习者。在实际应用场景中,开发者常面临编译器配置

weixin_33714884的博客 317

Ubuntu Terminal 打开 Code::Blocks

Ubuntu Terminal 打开 Code::Blocks

程永强 1893

虚拟机Linux安装CodeBlocks安装说明

虚拟机Linux安装CodeBlocks安装说明

Code::Blocks: The free C/C++ and Fortran IDE

Code::Blocks: The free C/C++ and Fortran IDE

程永强 1104

R语言maftools包实战:5分钟搞定TCGA癌症突变数据可视化(附完整代码)

本文详细介绍了如何使用R语言的maftools包快速解析和可视化TCGA癌症突变数据。通过实战演示,从环境搭建、数据导入到核心可视化(如瀑布图、棒棒糖图)和深度统计分析(如生存分析、突变特征),帮助生物信息学研究者高效完成癌症基因组学分析,大幅提升从原始MAF数据到发表级图表的效率。

weixin_29054399的博客 187

第二次 PX4仿真环境搭建过程全记录

参考链接 https://blog.youkuaiyun.com/yanwumuxi/article/details/80097294 https://www.ncnynl.com/archives/201709/2013.html 一、安装依赖项 我们使用Debian / Ubuntu LTS 作为Linux的标准支持版本,但是也支持Cent OS 和 Arch Linux的发行版本。 权限设置 警告:永远...

移步换景的博客 2261

更换编译器,CODE::BLOCKS 无法DEBUG 至断点

 想在LINUX下使用CODE::BLOCKS 编写调试并编译连接ARM运行程序。IDE编译环境默认为:GNU GCC 编译器。修改如下:1. 至Settings->Compiler and debugger settings 将Setected compiler 修改为GNU ARM GCC 编译器。2.在同页面选择子页‘Toolchain executables’->program file

qicksand的专栏 1909

Hifiasm参数调优实战:当N50不理想时的7个排查方向与解决方案

本文详细解析了Hifiasm参数调优实战,针对基因组组装中N50不理想的7个排查方向与解决方案。通过调整--hom-cov、-D、-N等核心参数,结合HiFi数据和参考基因组分析,有效提升组装质量。文章以猪毛菜基因组为例,展示了从2.1MB到4.3MB的N50优化过程,为生物信息学研究者提供实用指南。

weixin_30642561的博客 425

Claude Code终端安装实战:Mac/Linux/Windows全平台打通指南

终端是AI编程工具与本地环境交互的唯一信道,其本质是进程调度、环境变量加载与系统API调用的综合载体。理解终端工作原理,才能突破命令不可用、PATH失效、权限拒绝等高频卡点。Claude Code作为深度集成本地文件系统与命令执行的大模型客户端,其安装过程实为一次终端可信通道的构建实践——需直面macOS Zsh配置静默加载、Linux发行版碎片化依赖、Windows ConPTY进程隔离等底层差异。本文聚焦零基础用户真实痛点,提供可验证、可复现、带原理说明的三平台原子化部署方案,并自然延伸至tmux会话持

dicha7140的博客 772

AIAgent知识表示与推理:基于本体论与规则引擎的实现

AIAgent知识表示与推理:基于本体论与规则引擎的实现 1. 背景介绍 人工智能(AI)系统的核心是知识表示和推理,这是实现智能行为的基础。在过去的几十年里,人工智能领域一直致力于研究如何有效地表示和推理知识,以支持智能系统的决策和行为。其中,基于本体论的知识表示和

AI天才研究院 1490

python-调用动态链接库dll/so的方法

使用python ctyeps CDLL来调用linux下的so动态链接库或windows下的dll动态链接库

XIAOXIANG233233的博客 3662

基于Codeblock的LVGL模拟器Windows平台环境搭建[带源码]

最近在折腾使用ESP32基于Arduino运行lvgl,但是Arduino编译esp32的速度属实着急,至少5分钟一次,稍微复杂点能上十分钟,属实折磨,在开发的时候及其影响效率,还是需要一个模拟器,这里记录下折腾模拟器踩过的坑。

hmc_123的博客 4055

告别Python依赖!用C++编译PaddleOCR打造轻量级本地OCR工具(附模型选择与性能对比)

本文详细介绍了如何将PaddleOCR从Python迁移到C++平台,打造高性能、低资源占用的本地OCR工具。通过对比Python和C++实现的性能差异,展示了C++在冷启动时间、内存占用和部署便捷性上的显著优势。文章还提供了模型选择、编译配置和优化技巧等实用指南,帮助开发者轻松构建轻量级OCR解决方案。

weixin_28717467的博客 256

source insight 调用标准C函数时提示方法

原文出处: http://www.cnblogs.com/qq78292959/archive/2012/03/21/2409378.html 输入自定义函数时会代码提示 输入标准C函数时没有提示解决方法   Options->Prefernces->Create Common Projects->Standrd C/C++ and Windows Headers "...

qq_33140565的博客 780

Oracle11g下载与安装(windows)

一、Oracle11g下载 二、安装准备 三、执行安装步骤 四、测试连接 附:Oracle11g服务说明

欢迎订阅我的“JAVA全栈开发笔记(全)”专栏,价格优惠,仅需19.9元。 2万+

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

上一篇: 今天编译通过Mpeg4ip和darwin streamer server
下一篇: VS.NET+ASP.NET+SQL Server2000安装与配置
emlinux
博客等级 码龄20年 18粉丝 41原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值