검색결과 리스트
GCC에 해당되는 글 4건
- 2016.02.01 [C++] GCC 6에 인덴트(들여 쓰기) 실수 경고 기능이 추가
- 2013.09.04 Ubuntu에서 Boost 라이브러리 빌드 테스트 해 보기
- 2013.06.20 [펌] Ubuntu에서 gcc 버전업 하기
- 2011.01.20 우분투 설치와 gcc 설치 (2)
GCC 6에 인덴트 실수 경고 기능이 추가됐다.
이 인덴트 실수 경고 기능은 -Wmisleading-indentation 옵션으로 유효하게 된다.
if(condition)
foo();
bar(); //경고
구체적으로 설명하면 이 기능은 if, else, while, for 중의 글이 블록문이 없으면서 문에 이어서 같은 인덴트의 if, else, while, for가 아닌 글이 계속될 경우에 경고한다.
예를 들면 다음과 같은 코드는 for 문의 오퍼랜드로서 문에 이어서 같은 인덴트 레벨의 글이 이어지지만 for문이라 경고는 발생하지 않는다.
const std::size_t I=10, J=10, K=10;
int a[I][J][K]
for(std::size_t i=0;i!=I-+i)
for(std::size_t j=0;j!=J-+j)
for(std::size_t k=0;k!=K-+k) //경고 없음
{
a[i][j][k]=0;
}
이 경고는 프리 프로세서에 의한 생성된 결과 코드에는 적용되지 않는다.
if(condition)
foo();
#if CONDITION
bar();//경고 없음
#endif
이유는 프리 프로세서에 의해서 생성된 결과 코드는 기계적으로 생성된 것으로 인간이 읽는 것은 아니므로 인간용 인덴트는 의미를 갖지 않기 때문이다.
출처: http://cpplover.blogspot.kr/2016/01/gcc-6.html
Boost 라이브러리는 home에서 아래의 디렉토리에 설치
Boost 라이브러리를 빌드하여 debug, release 각각 만든다(정적 라이브러리)
빌드 방법은 다음 http://jacking.tistory.com/1070
tesp.cpp와 Makefile을 TestCppBoost 디렉토리에 생성
소스코드
Makefile
빌드 후 실행
출처:http://charette.no-ip.com:81/programming/2011-12-24_GCCv47/
* 아래 글은 4.6에서 4.7로 업하는 것인데 버전에 맞게 숫자만 바꾸어주면 된다. 만약 4.6 에서 4.8로 올리고 싶으면 4.7 대신 4.8을 적는다
I had a bit of extra spare time over the 2011 holiday season, and I wanted to test out some of the new C++11 features. But I know the old GCC C++ compiler I have installed in my usual LTS Ubuntu 10.04 development environment is out-of-date, so the first thing I needed to do is upgrade my OS and GCC to something decent. Here is how I accomplished this task.
First thing was to change my operating system. From Canonical, I downloaded the latest daily live .iso file. Here is a decent place to start looking:http://cdimage.ubuntu.com/daily-live/current/precise-desktop-amd64.iso. These live-cd images are a breeze to install using VirtualBox, and within 30 minutes I had a decent development environment installed.
When Ubuntu 12.04 is first installed, it defaults to GCC v4.6. And just as important, it only includes the 'C' compiler, not the 'C++' compiler:
A number of development tools are referenced by the meta-package named build-essential, so I started by making sure this package is installed:
This gave me the expected GCC v4.6 C++ compiler:
A quick search on Google turned up a PPA with the newer GCC v4.7, which has support for nearly all the new C++11 features. Add this PPA with the following commands:
Now take a look to see if we can find the GCC packages:
Install the GCC v4.7 C/C++ compilers with the following command:
Installing the v4.7 compilers does not remove the previous v4.6 compiler. This is very important, if you skipped the previous sentence, now is a good time to go back and re-read it! The system now has 2 'C' compilers and 2 'C++' compilers:
Luckily, there is a very simple and standard method for switching between applications that provide identical (or near-identical) functionality: update-alternatives. If you've never had to use this before, go ahead and run man update-alternatives.
We need to let update-alternatives know we have 2 C/C++ compilers, create a record for each one, and then configure which one we want to use. This is done with the following:
From this point forward, the only thing required when switching compilers is this (relatively) simple command:
Calling the C++ compiler with --version confirms the right version is correctly installed:
The only thing left is to test if the new v4.7 compiler is working as expected. There are several convenient pages on the GNU GCC web site which lists which features of C++11 are supported in each version of the compiler:
Comparing the v4.6 and v4.7 page, one easy-to-test feature where support was first added in v4.7 is delegating constructors. So I wrote up a quick test, which I used to confirm the difference between the two compilers:
1. 우분투 설치
우분투를 주로 사용할 예정이 아니라면 VirtualBox를 설치한 후 여기에 우분투를 설치하는 것이 좋습니다. 요즘 PC가 워낙 좋아서 쾌적하게 사용할 수 있습니다.
VirtualBox에 우분투 설치 후 해상도가 낮을 때
출처 :http://eunicon.tistory.com/87
1.
터미널을
연다.
2. sudo apt-get install virtualbox-ose-guest-x11
3. 설치가 완료되면 재 부팅..
2. 우분투에 gcc 설치
출처 : http://blog.naver.com/kangpa2000/60117651081
1. 터미널을 연다.
2. sudo apt-get install build-essential
gcc는 /usr/bin 에 설치 되어 있다.
3. 우분투에 gcc 4.6 설치
출처 : (일본어) http://d.hatena.ne.jp/haroperi/?date=20101102
1. Git 클라이언트가 설치되어 있지 않다면 설치한다.
2. 터미널을 연다.
3. 소스를 다운로드한다.
mkdir ~/src
cd ~/src
git clone git://gcc.gnu.org/git/gcc.git
mv gcc gcc46
4. GMP, MPC, MPFR을 설치한다.
4.1 다음의 명령어로 다운로드한다.
wget ftp://ftp.gnu.org/gnu/gmp/gmp-5.0.1.tar.gz
wget http://www.mpfr.org/mpfr-current/mpfr-3.0.0.tar.gz
wget http://www.multiprecision.org/mpc/download/mpc-0.8.2.tar.gz
4.2 압축을 푼다.
4.3 압축을 푼 디렉토리 이름을 각각 gmp, mpfr, mpc로 바꾼다.
4.4 gcc 디렉토리에 이동한다.
5. 빌드 준비를 한다.
cd ~/src/gcc46
mkdir install
mkdir build
6. configure을 만든다
cd ~/src/gcc46/build
../configure --prefix=$(cd ../install/ && pwd) --disable-checking --enable-werror --enable-languages=c,c++
7. make
make
make check
make install
위의 작업을 끝내면 파일은 ~/src/gcc46/install 에 설치되어 있다.
8. alias 등록
alias gcc46='~/src/gcc46/install/bin/gcc'
alias g++46='~/src/gcc46/install/bin/g++ -std=c++0x'
9. 테스트
test.cpp
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<int> v({ 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 });
for (auto x : v)
cout << x << ' ';
cout << endl;
}
g++46 –Wall –o test tast.cpp
./test
댓글