GCC Build With Strange Errors

link: http://modest-destiny.net/wp/?p=77

GCC Build With Strange Errors

I have been fighting with these strange errors for some days, and finally I got it.

Problem

The core problem is that my C_INCLUDE_PATH and CPLUS_INCLUDE_PATHends with a colon. Path ending with a colon will include current path, aka./ which caused the error.

Solution

We need to remove the trailing colon, so I write a bash function for it.

# usage: removeTrailingColon str
# example:
#    C_INCLUDE_PATH=$(removeTrailingColon $C_INCLUDE_PATH)
removeTrailingColon() {
    if [[ $1 == *: ]]
    then
        local strColonRemoved=$1;
        local strColonRemoved=${strColonRemoved:0:(-1)};
        echo $strColonRemoved;
    else
        echo $1
    fi
}

Usage is like this:

export C_INCLUDE_PATH=$(removeTrailingColon $C_INCLUDE_PATH)
export CPLUS_INCLUDE_PATH=$(removeTrailingColon $CPLUS_INCLUDE_PATH)
export LD_LIBRARY_PATH=$(removeTrailingColon $LD_LIBRARY_PATH)
export LIBRARY_PATH=$(removeTrailingColon $LIBRARY_PATH)

Elaborate on problem

I’ll list the error I encountered building gcc-4.7.3, so that people will be able to access it through a search engine:

In file included from ../.././gcc/c-lang.c:24:
../.././gcc/system.h:499: error: conflicting types for strsignal
/usr/include/string.h:566: note: previous declaration of strsignal was here
In file included from ./tm.h:19,
                 from ../.././gcc/c-lang.c:26:
./options.h:3750:2: error: #error too many masks for ix86_isa_flags
In file included from ../.././gcc/input.h:25,
                 from ../.././gcc/tree.h:27,
                 from ../.././gcc/c-lang.c:27:
../.././gcc/../libcpp/include/line-map.h:208: error: CHAR_BIT undeclared here (not in a function)
../.././gcc/../libcpp/include/line-map.h:208: error: bit-field reason width not an integer constant
../.././gcc/../libcpp/include/line-map.h:208: warning: reason is narrower than values of its type
In file included from ../.././gcc/tree.h:32,
                 from ../.././gcc/c-lang.c:27:
../.././gcc/real.h:87:5: error: division by zero in #if
../.././gcc/real.h:87:5: error: division by zero in #if
../.././gcc/real.h:90:6: error: division by zero in #if
../.././gcc/real.h:90:6: error: division by zero in #if
../.././gcc/real.h:93:7: error: division by zero in #if
../.././gcc/real.h:93:7: error: division by zero in #if
../.././gcc/real.h:96:8: error: division by zero in #if
../.././gcc/real.h:96:8: error: division by zero in #if
../.././gcc/real.h:99:9: error: division by zero in #if
../.././gcc/real.h:99:9: error: division by zero in #if
../.././gcc/real.h:102:10: error: division by zero in #if
../.././gcc/real.h:102:10: error: division by zero in #if
../.././gcc/real.h:105:9: error: #error "REAL_WIDTH > 6 not supported"
In file included from ../.././gcc/c-family/c-common.h:26,
                 from ../.././gcc/c-tree.h:25,
                 from ../.././gcc/c-lang.c:28:
../.././gcc/../libcpp/include/cpplib.h:225: error: bit-field type width not an integer constant
../.././gcc/../libcpp/include/cpplib.h:225: warning: type is narrower than values of its type
In file included from ../.././gcc/c-family/c-common.h:26,
                 from ../.././gcc/c-tree.h:25,
                 from ../.././gcc/c-lang.c:28:
../.././gcc/../libcpp/include/cpplib.h:267:3: error: #error "Cannot find a least-32-bit signed integer type"
../.././gcc/../libcpp/include/cpplib.h:269: error: expected ‘=’, ‘,’, ‘;’, asm or __attribute__ before cppchar_t
../.././gcc/../libcpp/include/cpplib.h:270: error: expected ‘=’, ‘,’, ‘;’, asm or __attribute__ before cppchar_signed_t
../.././gcc/../libcpp/include/cpplib.h:768: error: expected ‘=’, ‘,’, ‘;’, asm or __attribute__ before cpp_interpret_charconst
../.././gcc/../libcpp/include/cpplib.h:779: error: expected ‘=’, ‘,’, ‘;’, asm or __attribute__ before cpp_host_to_exec_charset
../.././gcc/../libcpp/include/cpplib.h:954: error: expected ‘=’, ‘,’, ‘;’, asm or __attribute__ before cpp_parse_escape
make[2]: *** [c-lang.o] Error 1

Add Apache2 Perl Support in Ubuntu 12.04

Add Apache2 Perl Support in Ubuntu 12.04

  • sudo apt-get install libapache2-mod-perl2 (if Ubuntu Server use aptitude install)
  • ( if the perl-mod is not enabled, you may use: sudo a2enmod perl )
  • mkdir ~/www/cgi-bin (it could be anywhere, just take it as an example)
  • Add the following code to /etc/apache2/sites-enabled/000-default file before </VirtualHost> line.
# Use 'ModPerl' module to process '.pl' and '.cgi' file
<Files ~ "\.(pl|cgi)$">
    SetHandler perl-script
    PerlResponseHandler ModPerl::PerlRun
    Options +ExecCGI
    PerlSendHeader On
</Files>

# Use '/home/www/cgi-bin/' as a CGI Directory
ScriptAlias /cgi-bin/ /home/www/cgi-bin/
<Directory "/home/www/cgi-bin/">
    Options ExecCGI
    AddHandler cgi-script cgi pl
</Directory>
  • Restart the apache2 service: sudo service apache2 restart
  • Test the perl environment:
  • Create file test.pl in /home/www/cgi-bin/:
#!/usr/bin/perl -w
print "Content-type: text/html\r\n\r\n";
print "Hello there!<br />\nJust testing .<br />\n";

for ($i=0; $i<10; $i++)
{
print $i."<br />";
}
  • Note 1: #!/usr/bin/perl -w is used to locate the perl parser which could be located by which perl.
  • Note 2: code print "Content-type: text/html\r\n\r\n"; is required to make it a valid CGI program.

chkconfig on Ubuntu 12.04 causing '/sbin/insserv: No such file or directory' Problem

chkconfig on Ubuntu 12.04 causing ‘/sbin/insserv: No such file or directory’ Problem

Problem Description:

I tried to start sshd at boot using chkconfig on Ubuntu 12.04.

As a result, I used `chkconfig --level 35 ssh on` to start it as default, however I got the following error.

/sbin/insserv: No such file or directory
/sbin/insserv: No such file or directory

How to solve:

ln -s /usr/lib/insserv/insserv /sbin/insserv

 

ZSH中禁止autocorrect

如果你在zsh中鍵入的命令中有誤,它會提示你是否要correct。

比如:

如果你在zsh中鍵入ks,它會提示你是否要換成ls,如下:

% ks
zsh: correct ‘ks’ to ‘ls’ [nyae]?

如果你覺得特別麻煩,你可以整體禁用所有的autocorrect。

在~/.zshrc中添加如下代碼:

unsetopt correct_all

注:更新版的ZSH,使用的option是這樣的

unsetopt correct

即可達到你的要求。

 

如果你只是想某些情況下不使用autocorrect,那麼你可以試試使用alias,比如:

alias vim = 'nocorrect vim '

 

「轉」理解Linux系统负荷

感謝:http://kb.cnblogs.com/page/110366/

一、查看系统负荷

  如果你的电脑很慢,你或许想查看一下,它的工作量是否太大了。

  一般在Linux系统中,我们使用uptime命令(w命令和top命令也行)。(另外,它们在苹果公司的Mac电脑上也适用。)

  你在终端窗口键入uptime,系统会返回一行信息。

Read more