Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB
ÈÈÃűêÇ©£º c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 ×îÐÂÎÄÕ : c++

C/C++³ÌÐòԱӦƸ³£¼ûÃæÊÔÌâÉîÈëÆÊÎö£¨×ªÔØ£©


1.ÒýÑÔ
  ±¾ÎĵÄд×÷Ä¿µÄ²¢²»ÔÚÓÚÌṩC/C++³ÌÐòÔ±ÇóÖ°ÃæÊÔÖ¸µ¼£¬¶øÖ¼ÔÚ´Ó¼¼ÊõÉÏ·ÖÎöÃæÊÔÌâµÄÄÚº­¡£ÎÄÖеĴó¶àÊýÃæÊÔÌâÀ´×Ô¸÷´óÂÛ̳£¬²¿·ÖÊÔÌâ½â´ðÒ²²Î¿¼ÁËÍøÓѵÄÒâ¼û­¡£
Ðí¶àÃæÊÔÌâ¿´ËƼòµ¥£¬È´ÐèÒªÉîºñµÄ»ù±¾¹¦²ÅÄܸø³öÍêÃÀµÄ½â´ð¡£ÆóÒµÒªÇóÃæÊÔÕßдһ¸ö×î¼òµ¥µÄstrcpyº¯Êý¶¼¿É¿´³öÃæÊÔÕßÔÚ¼¼ÊõÉϾ¿¾¹´ïµ½ÁËÔõÑùµÄ³Ì
¶È£¬ÎÒÃÇÄÜÕæÕýдºÃÒ»¸östrcpyº¯ÊýÂð£¿ÎÒÃǶ¼¾õµÃ×Ô¼ºÄÜ£¬¿ÉÊÇÎÒÃÇд³öµÄstrcpyºÜ¿ÉÄÜÖ»ÄÜÄõ½10·ÖÖеÄ2·Ö¡£¶ÁÕß¿É´Ó±¾ÎÄ¿´µ½strcpy
º¯Êý´Ó2·Öµ½10·Ö½â´ðµÄÀý×Ó£¬¿´¿´×Ô¼ºÊôÓÚʲôÑùµÄ²ã´Î¡£´ËÍ⣬»¹ÓÐһЩÃæÊÔÌ⿼²éÃæÊÔÕßÃô½ÝµÄ˼άÄÜÁ¦¡£
  ·ÖÎöÕâЩÃæÊÔÌ⣬±¾Éí°üº¬ºÜÇ¿µÄȤζÐÔ£»¶ø×÷ΪһÃûÑз¢ÈËÔ±£¬Í¨¹ý¶ÔÕâЩÃæÊÔÌâµÄÉîÈëÆÊÎöÔò¿É½øÒ»²½ÔöÇ¿×ÔÉíµÄÄÚ¹¦¡£
2.ÕÒ´íÌâ
  ÊÔÌâ1£º
void test1()
{
char string[10];
char* str1 = "0123456789";
strcpy( string, str1 );
}
  ÊÔÌâ2£º
void test2()
{
char string[10], str1[10];
int i;
for(i=0; i<10; i++)
{
  str1[i] = 'a'£»
}
strcpy( string, str1 )£»
}
  ÊÔÌâ3£º
void ......

C/C++³ÌÐòԱӦƸ³£¼ûÃæÊÔÌâÉîÈëÆÊÎö£¨×ªÔØ£©


1.ÒýÑÔ
  ±¾ÎĵÄд×÷Ä¿µÄ²¢²»ÔÚÓÚÌṩC/C++³ÌÐòÔ±ÇóÖ°ÃæÊÔÖ¸µ¼£¬¶øÖ¼ÔÚ´Ó¼¼ÊõÉÏ·ÖÎöÃæÊÔÌâµÄÄÚº­¡£ÎÄÖеĴó¶àÊýÃæÊÔÌâÀ´×Ô¸÷´óÂÛ̳£¬²¿·ÖÊÔÌâ½â´ðÒ²²Î¿¼ÁËÍøÓѵÄÒâ¼û­¡£
Ðí¶àÃæÊÔÌâ¿´ËƼòµ¥£¬È´ÐèÒªÉîºñµÄ»ù±¾¹¦²ÅÄܸø³öÍêÃÀµÄ½â´ð¡£ÆóÒµÒªÇóÃæÊÔÕßдһ¸ö×î¼òµ¥µÄstrcpyº¯Êý¶¼¿É¿´³öÃæÊÔÕßÔÚ¼¼ÊõÉϾ¿¾¹´ïµ½ÁËÔõÑùµÄ³Ì
¶È£¬ÎÒÃÇÄÜÕæÕýдºÃÒ»¸östrcpyº¯ÊýÂð£¿ÎÒÃǶ¼¾õµÃ×Ô¼ºÄÜ£¬¿ÉÊÇÎÒÃÇд³öµÄstrcpyºÜ¿ÉÄÜÖ»ÄÜÄõ½10·ÖÖеÄ2·Ö¡£¶ÁÕß¿É´Ó±¾ÎÄ¿´µ½strcpy
º¯Êý´Ó2·Öµ½10·Ö½â´ðµÄÀý×Ó£¬¿´¿´×Ô¼ºÊôÓÚʲôÑùµÄ²ã´Î¡£´ËÍ⣬»¹ÓÐһЩÃæÊÔÌ⿼²éÃæÊÔÕßÃô½ÝµÄ˼άÄÜÁ¦¡£
  ·ÖÎöÕâЩÃæÊÔÌ⣬±¾Éí°üº¬ºÜÇ¿µÄȤζÐÔ£»¶ø×÷ΪһÃûÑз¢ÈËÔ±£¬Í¨¹ý¶ÔÕâЩÃæÊÔÌâµÄÉîÈëÆÊÎöÔò¿É½øÒ»²½ÔöÇ¿×ÔÉíµÄÄÚ¹¦¡£
2.ÕÒ´íÌâ
  ÊÔÌâ1£º
void test1()
{
char string[10];
char* str1 = "0123456789";
strcpy( string, str1 );
}
  ÊÔÌâ2£º
void test2()
{
char string[10], str1[10];
int i;
for(i=0; i<10; i++)
{
  str1[i] = 'a'£»
}
strcpy( string, str1 )£»
}
  ÊÔÌâ3£º
void ......

LinuxÏÂÓÃeclipseдC/C++ÓïÑÔ³ÌÐòµÄ±àÒëÎÊÌâ

µ±Òª½¨Á¢Ï̵߳Èʱ£¬ÔÚLinuxÏ£¬ÓÃÎı¾±à¼­£¬ÔÚ¼üÈë“g++ -lpthread”.......“¿ÉÒÔ°Ñ¿âpthreadÒýÈ딣¬±àÒëͨ¹ý¡£ÏÖÔÚÏëÓÃeclipse£¬µ«ÊÇĬÈÏÇé¿öÏ£¬ÒýÈë²»ÁËpthread¡£»á±¨“undefined reference to phread_create”µÈ´íÎó¡£
½â¾ö·½·¨£º¿ÉÒÔÔÚprojectÖкõ½properties
ÔÚÀïÃæµÄ“Tool Settings”£»ÀïÕÒµ½“GCC C++ Linker”¡£
ÔÚÆäÖеēLibraries”ÉÏÌí¼Ó“pthread”£¬°´“ok”£¬ÖØбàÒë¾Í¿ÉÒÔÁË¡£ ......

LinuxÏÂÓÃeclipseдC/C++ÓïÑÔ³ÌÐòµÄ±àÒëÎÊÌâ

µ±Òª½¨Á¢Ï̵߳Èʱ£¬ÔÚLinuxÏ£¬ÓÃÎı¾±à¼­£¬ÔÚ¼üÈë“g++ -lpthread”.......“¿ÉÒÔ°Ñ¿âpthreadÒýÈ딣¬±àÒëͨ¹ý¡£ÏÖÔÚÏëÓÃeclipse£¬µ«ÊÇĬÈÏÇé¿öÏ£¬ÒýÈë²»ÁËpthread¡£»á±¨“undefined reference to phread_create”µÈ´íÎó¡£
½â¾ö·½·¨£º¿ÉÒÔÔÚprojectÖкõ½properties
ÔÚÀïÃæµÄ“Tool Settings”£»ÀïÕÒµ½“GCC C++ Linker”¡£
ÔÚÆäÖеēLibraries”ÉÏÌí¼Ó“pthread”£¬°´“ok”£¬ÖØбàÒë¾Í¿ÉÒÔÁË¡£ ......

LinuxÏÂÓÃeclipseдC/C++ÓïÑÔ³ÌÐòµÄ±àÒëÎÊÌâ

µ±Òª½¨Á¢Ï̵߳Èʱ£¬ÔÚLinuxÏ£¬ÓÃÎı¾±à¼­£¬ÔÚ¼üÈë“g++ -lpthread”.......“¿ÉÒÔ°Ñ¿âpthreadÒýÈ딣¬±àÒëͨ¹ý¡£ÏÖÔÚÏëÓÃeclipse£¬µ«ÊÇĬÈÏÇé¿öÏ£¬ÒýÈë²»ÁËpthread¡£»á±¨“undefined reference to phread_create”µÈ´íÎó¡£
½â¾ö·½·¨£º¿ÉÒÔÔÚprojectÖкõ½properties
ÔÚÀïÃæµÄ“Tool Settings”£»ÀïÕÒµ½“GCC C++ Linker”¡£
ÔÚÆäÖеēLibraries”ÉÏÌí¼Ó“pthread”£¬°´“ok”£¬ÖØбàÒë¾Í¿ÉÒÔÁË¡£ ......

C/C++ static µÄ×÷ÓÃ

ת×Ô£ºhttp://blog.csdn.net/xiaocai0001/archive/2006/04/14/662921.aspx
static¹Ø¼ü×ÖÊÇC, C++Öж¼´æÔڵĹؼü×Ö, ËüÖ÷ÒªÓÐÈýÖÖʹÓ÷½Ê½, ÆäÖÐÇ°Á½ÖÖÔÚC/C++ÓïÑÔÖÐʹÓÃ, µÚÈýÖÖÖ»ÔÚC++ÖÐʹÓÃ(C,C++ÖоßÌåϸ΢²Ù×÷²»¾¡Ïàͬ, ±¾ÎÄÒÔC++Ϊ׼).
(1)¾Ö²¿¾²Ì¬±äÁ¿
(2)Íⲿ¾²Ì¬±äÁ¿/º¯Êý
(3)¾²Ì¬Êý¾Ý³ÉÔ±/³ÉÔ±º¯Êý
ÏÂÃæ¾ÍÕâÈýÖÖʹÓ÷½Ê½¼°×¢ÒâÊÂÏî·Ö±ð˵Ã÷
Ò»¡¢¾Ö²¿¾²Ì¬±äÁ¿
ÔÚC/C++ÖÐ, ¾Ö²¿±äÁ¿°´ÕÕ´æ´¢ÐÎʽ¿É·ÖΪÈýÖÖauto, static, register
(<CÓïÑÔ³ÌÐòÉè¼Æ(µÚ¶þ°æ)>Ì·ºÆÇ¿, µÚ174-175Ò³)
ÓëautoÀàÐÍ(ÆÕͨ)¾Ö²¿±äÁ¿Ïà±È, static¾Ö²¿±äÁ¿ÓÐÈýµã²»Í¬
1. ´æ´¢¿Õ¼ä·ÖÅ䲻ͬ
autoÀàÐÍ·ÖÅäÔÚÕ»ÉÏ, ÊôÓÚ¶¯Ì¬´æ´¢Àà±ð, Õ¼¶¯Ì¬´æ´¢Çø¿Õ¼ä, º¯Êýµ÷ÓýáÊøºó×Ô¶¯ÊÍ·Å, ¶østatic·ÖÅäÔÚ¾²Ì¬´æ´¢Çø, ÔÚ³ÌÐòÕû¸öÔËÐÐÆڼ䶼²»ÊÍ·Å. Á½ÕßÖ®¼äµÄ×÷ÓÃÓòÏàͬ, µ«Éú´æÆÚ²»Í¬.
2. static¾Ö²¿±äÁ¿ÔÚËù´¦Ä£¿éÔÚ³õ´ÎÔËÐÐʱ½øÐгõʼ»¯¹¤×÷, ÇÒÖ»²Ù×÷Ò»´Î
3. ¶ÔÓÚ¾Ö²¿¾²Ì¬±äÁ¿, Èç¹û²»¸³³õÖµ, ±àÒëÆÚ»á×Ô¶¯¸³³õÖµ0»ò¿Õ×Ö·û, ¶øautoÀàÐ͵ijõÖµÊDz»È·¶¨µÄ. (¶ÔÓÚC++ÖеÄclass¶ÔÏóÀýÍâ, classµÄ¶ÔÏóʵÀýÈç¹û²»³õʼ»¯, Ôò»á×Ô¶¯µ÷ÓÃĬÈϹ¹Ô캯Êý, ²»¹ÜÊÇ·ñÊÇstaticÀàÐÍ)
Ìصã: static¾Ö²¿±äÁ¿ ......

C/C++ static µÄ×÷ÓÃ

ת×Ô£ºhttp://blog.csdn.net/xiaocai0001/archive/2006/04/14/662921.aspx
static¹Ø¼ü×ÖÊÇC, C++Öж¼´æÔڵĹؼü×Ö, ËüÖ÷ÒªÓÐÈýÖÖʹÓ÷½Ê½, ÆäÖÐÇ°Á½ÖÖÔÚC/C++ÓïÑÔÖÐʹÓÃ, µÚÈýÖÖÖ»ÔÚC++ÖÐʹÓÃ(C,C++ÖоßÌåϸ΢²Ù×÷²»¾¡Ïàͬ, ±¾ÎÄÒÔC++Ϊ׼).
(1)¾Ö²¿¾²Ì¬±äÁ¿
(2)Íⲿ¾²Ì¬±äÁ¿/º¯Êý
(3)¾²Ì¬Êý¾Ý³ÉÔ±/³ÉÔ±º¯Êý
ÏÂÃæ¾ÍÕâÈýÖÖʹÓ÷½Ê½¼°×¢ÒâÊÂÏî·Ö±ð˵Ã÷
Ò»¡¢¾Ö²¿¾²Ì¬±äÁ¿
ÔÚC/C++ÖÐ, ¾Ö²¿±äÁ¿°´ÕÕ´æ´¢ÐÎʽ¿É·ÖΪÈýÖÖauto, static, register
(<CÓïÑÔ³ÌÐòÉè¼Æ(µÚ¶þ°æ)>Ì·ºÆÇ¿, µÚ174-175Ò³)
ÓëautoÀàÐÍ(ÆÕͨ)¾Ö²¿±äÁ¿Ïà±È, static¾Ö²¿±äÁ¿ÓÐÈýµã²»Í¬
1. ´æ´¢¿Õ¼ä·ÖÅ䲻ͬ
autoÀàÐÍ·ÖÅäÔÚÕ»ÉÏ, ÊôÓÚ¶¯Ì¬´æ´¢Àà±ð, Õ¼¶¯Ì¬´æ´¢Çø¿Õ¼ä, º¯Êýµ÷ÓýáÊøºó×Ô¶¯ÊÍ·Å, ¶østatic·ÖÅäÔÚ¾²Ì¬´æ´¢Çø, ÔÚ³ÌÐòÕû¸öÔËÐÐÆڼ䶼²»ÊÍ·Å. Á½ÕßÖ®¼äµÄ×÷ÓÃÓòÏàͬ, µ«Éú´æÆÚ²»Í¬.
2. static¾Ö²¿±äÁ¿ÔÚËù´¦Ä£¿éÔÚ³õ´ÎÔËÐÐʱ½øÐгõʼ»¯¹¤×÷, ÇÒÖ»²Ù×÷Ò»´Î
3. ¶ÔÓÚ¾Ö²¿¾²Ì¬±äÁ¿, Èç¹û²»¸³³õÖµ, ±àÒëÆÚ»á×Ô¶¯¸³³õÖµ0»ò¿Õ×Ö·û, ¶øautoÀàÐ͵ijõÖµÊDz»È·¶¨µÄ. (¶ÔÓÚC++ÖеÄclass¶ÔÏóÀýÍâ, classµÄ¶ÔÏóʵÀýÈç¹û²»³õʼ»¯, Ôò»á×Ô¶¯µ÷ÓÃĬÈϹ¹Ô캯Êý, ²»¹ÜÊÇ·ñÊÇstaticÀàÐÍ)
Ìصã: static¾Ö²¿±äÁ¿ ......

linux ÏÂC¡¢C++±à³Ì×ÊÁÏ




GCC    ÖÐÎÄÊֲᠠ 
   ¡¡¡¡http://www.nbfan.com/forum/dispbbs....&ID=1433&page=1   
   ¡¡¡¡GNU    make    Ö¸ÄÏ   
   ¡¡¡¡http://www.linuxsir.org/bbs/showthr...&threadid=40431     
   ¡¡¡¡autoconf-2.57ÊÖ²á(Ó¢ÎÄ)   
   ¡¡¡¡http://www.gnu.org/software/autocon...toconf_toc.html     
   ¡¡¡¡Autoconf-2.13Êֲᠠ 
   ¡¡¡¡http://www.linuxforum.net/books/autoconf.html     
   ¡¡¡¡Ê¹Óà   automake   
   ¡¡¡¡http://263.aka.org.cn/Lectures/002/...-2.1.4/230.html     
   ¡¡¡¡Ê¹ÓÃCVS½øÐа汾¹ÜÀí   
   ¡¡¡¡http://www.linuxforum.net/books/cvsintro.html   & ......

linux ÏÂC¡¢C++±à³Ì×ÊÁÏ




GCC    ÖÐÎÄÊֲᠠ 
   ¡¡¡¡http://www.nbfan.com/forum/dispbbs....&ID=1433&page=1   
   ¡¡¡¡GNU    make    Ö¸ÄÏ   
   ¡¡¡¡http://www.linuxsir.org/bbs/showthr...&threadid=40431     
   ¡¡¡¡autoconf-2.57ÊÖ²á(Ó¢ÎÄ)   
   ¡¡¡¡http://www.gnu.org/software/autocon...toconf_toc.html     
   ¡¡¡¡Autoconf-2.13Êֲᠠ 
   ¡¡¡¡http://www.linuxforum.net/books/autoconf.html     
   ¡¡¡¡Ê¹Óà   automake   
   ¡¡¡¡http://263.aka.org.cn/Lectures/002/...-2.1.4/230.html     
   ¡¡¡¡Ê¹ÓÃCVS½øÐа汾¹ÜÀí   
   ¡¡¡¡http://www.linuxforum.net/books/cvsintro.html   & ......

linux ÏÂC¡¢C++±à³Ì×ÊÁÏ




GCC    ÖÐÎÄÊֲᠠ 
   ¡¡¡¡http://www.nbfan.com/forum/dispbbs....&ID=1433&page=1   
   ¡¡¡¡GNU    make    Ö¸ÄÏ   
   ¡¡¡¡http://www.linuxsir.org/bbs/showthr...&threadid=40431     
   ¡¡¡¡autoconf-2.57ÊÖ²á(Ó¢ÎÄ)   
   ¡¡¡¡http://www.gnu.org/software/autocon...toconf_toc.html     
   ¡¡¡¡Autoconf-2.13Êֲᠠ 
   ¡¡¡¡http://www.linuxforum.net/books/autoconf.html     
   ¡¡¡¡Ê¹Óà   automake   
   ¡¡¡¡http://263.aka.org.cn/Lectures/002/...-2.1.4/230.html     
   ¡¡¡¡Ê¹ÓÃCVS½øÐа汾¹ÜÀí   
   ¡¡¡¡http://www.linuxforum.net/books/cvsintro.html   & ......

organizing code files in C & C++

http://www.gamedev.net/reference/programming/features/orgfiles/page2.asp
ͨ¹ýËĸöpitfall½²½âÍ·ÎļþµÄÓÉÀ´ºÍºÃ´¦£¬ÒÔ¼°Ê¹ÓÃÍ·Îļþ¶¨Òåinline func and template.
Remember that, as far as the compiler is concerned, there is absolutely no difference between a header file and a source file.
The key idea is that headers contain the interface, and the source files contain the actual implementation.This means that one source file uses another source file via the second source file's header.
main body
By now you're probably convinced that there are benefits to splitting up your project into several smaller files. So, how would you go about it? Although some of the decisions you make will be reasonably arbitrary, there are some basic rules that you should follow to ensure that it all works.
Firstly, look at how you would split your code into sections. Often this is by splitting it into separate subsystems, or 'modules', such as sound, music, graphics, file handling, etc. Create new files wi ......

organizing code files in C & C++

http://www.gamedev.net/reference/programming/features/orgfiles/page2.asp
ͨ¹ýËĸöpitfall½²½âÍ·ÎļþµÄÓÉÀ´ºÍºÃ´¦£¬ÒÔ¼°Ê¹ÓÃÍ·Îļþ¶¨Òåinline func and template.
Remember that, as far as the compiler is concerned, there is absolutely no difference between a header file and a source file.
The key idea is that headers contain the interface, and the source files contain the actual implementation.This means that one source file uses another source file via the second source file's header.
main body
By now you're probably convinced that there are benefits to splitting up your project into several smaller files. So, how would you go about it? Although some of the decisions you make will be reasonably arbitrary, there are some basic rules that you should follow to ensure that it all works.
Firstly, look at how you would split your code into sections. Often this is by splitting it into separate subsystems, or 'modules', such as sound, music, graphics, file handling, etc. Create new files wi ......

LinuxÏÂC/C++±àÒëÆ÷gccʹÓüò½é

1.gcc°üº¬µÄc/c++±àÒëÆ÷
gcc,ccÓëc++,g++
gccºÍccÊÇÒ»ÑùµÄ£¬c++ºÍg++ÊÇÒ»ÑùµÄ¡£Ò»°ãc³ÌÐò¾ÍÓÃgcc±àÒ룬c++³ÌÐò¾ÍÓÃg++±àÒë¡£
2.gccµÄ»ù±¾Ó÷¨
gcc test.c£ºÈç¹ûûÓÐÖ¸¶¨Êä³öµÄÎļþ£¬Ä¬ÈϽ«±àÒë³öÒ»¸öÃûΪa.outµÄ³ÌÐò
gcc test.c -o test£º-o²ÎÊýÓÃÀ´Ö¸¶¨Éú³ÉÄ¿±ê³ÌÐòµÄÃû×Ö£¬ÕâÑù½«±àÒë³öÒ»¸öÃûΪtestµÄ³ÌÐò¡£
3.Ϊʲô»á³öÏÖundefined reference to 'xxxxx'´íÎó£¿
Ê×ÏÈÕâÊÇÁ´½Ó´íÎ󣬲»ÊDZàÒë´íÎó£¬Ò²¾ÍÊÇ˵Èç¹ûÖ»ÓÐÕâ¸ö´íÎó£¬ËµÃ÷ÄãµÄ³ÌÐòÔ´Âë±¾ÉíûÓÐÎÊÌ⣬ÊÇÄãÓñàÒëÆ÷±àÒëʱ²ÎÊýÓõò»¶Ô£¬ÄãûÓÐÖ¸¶¨Á´½Ó³ÌÐòÒªÓõ½µÃ¿â£¬±ÈÈçÄãµÄ³ÌÐòÀïÓõ½ÁËһЩÊýѧº¯Êý£¬ÄÇôÄã¾ÍÒªÔÚ±àÒë²ÎÊýÀïÖ¸¶¨³ÌÐòÒªÁ´½ÓÊýѧ¿â£¬·½·¨ÊÇÔÚ±àÒëÃüÁîÐÐÀï¼ÓÈë-lm¡£
4.-l²ÎÊýºÍ-L²ÎÊý
-l²ÎÊý¾ÍÊÇÓÃÀ´Ö¸¶¨³ÌÐòÒªÁ´½ÓµÄ¿â£¬-l²ÎÊý½ô½ÓמÍÊÇ¿âÃû£¬ÄÇô¿âÃû¸úÕæÕýµÄ¿âÎļþÃûÓÐʲô¹ØϵÄØ£¿¾ÍÄÃÊýѧ¿âÀ´Ëµ£¬ËûµÄ¿âÃûÊÇm£¬ËûµÄ¿âÎļþÃûÊÇlibm.so£¬ºÜÈÝÒ׿´³ö£¬°Ñ¿âÎļþÃûµÄÍ·libºÍβ.soÈ¥µô¾ÍÊÇ¿âÃûÁË¡£
ºÃÁËÏÖÔÚÎÒÃÇÖªµÀÔõôµÃµ½¿âÃûÁË£¬±ÈÈçÎÒÃÇ×ÔÒÑÒªÓõ½Ò»¸öµÚÈý·½ÌṩµÄ¿âÃû×Ö½Ðlibtest.so£¬ÄÇôÎÒÃÇÖ»Òª°Ñlibtest.so¿½±´µ½/usr/libÀ±àÒëʱ¼ÓÉÏ-ltest²ÎÊý£¬ÎÒÃǾÍÄÜÓÃÉÏlibtest.so¿âÁË£ ......

LinuxÏÂC/C++±àÒëÆ÷gccʹÓüò½é

1.gcc°üº¬µÄc/c++±àÒëÆ÷
gcc,ccÓëc++,g++
gccºÍccÊÇÒ»ÑùµÄ£¬c++ºÍg++ÊÇÒ»ÑùµÄ¡£Ò»°ãc³ÌÐò¾ÍÓÃgcc±àÒ룬c++³ÌÐò¾ÍÓÃg++±àÒë¡£
2.gccµÄ»ù±¾Ó÷¨
gcc test.c£ºÈç¹ûûÓÐÖ¸¶¨Êä³öµÄÎļþ£¬Ä¬ÈϽ«±àÒë³öÒ»¸öÃûΪa.outµÄ³ÌÐò
gcc test.c -o test£º-o²ÎÊýÓÃÀ´Ö¸¶¨Éú³ÉÄ¿±ê³ÌÐòµÄÃû×Ö£¬ÕâÑù½«±àÒë³öÒ»¸öÃûΪtestµÄ³ÌÐò¡£
3.Ϊʲô»á³öÏÖundefined reference to 'xxxxx'´íÎó£¿
Ê×ÏÈÕâÊÇÁ´½Ó´íÎ󣬲»ÊDZàÒë´íÎó£¬Ò²¾ÍÊÇ˵Èç¹ûÖ»ÓÐÕâ¸ö´íÎó£¬ËµÃ÷ÄãµÄ³ÌÐòÔ´Âë±¾ÉíûÓÐÎÊÌ⣬ÊÇÄãÓñàÒëÆ÷±àÒëʱ²ÎÊýÓõò»¶Ô£¬ÄãûÓÐÖ¸¶¨Á´½Ó³ÌÐòÒªÓõ½µÃ¿â£¬±ÈÈçÄãµÄ³ÌÐòÀïÓõ½ÁËһЩÊýѧº¯Êý£¬ÄÇôÄã¾ÍÒªÔÚ±àÒë²ÎÊýÀïÖ¸¶¨³ÌÐòÒªÁ´½ÓÊýѧ¿â£¬·½·¨ÊÇÔÚ±àÒëÃüÁîÐÐÀï¼ÓÈë-lm¡£
4.-l²ÎÊýºÍ-L²ÎÊý
-l²ÎÊý¾ÍÊÇÓÃÀ´Ö¸¶¨³ÌÐòÒªÁ´½ÓµÄ¿â£¬-l²ÎÊý½ô½ÓמÍÊÇ¿âÃû£¬ÄÇô¿âÃû¸úÕæÕýµÄ¿âÎļþÃûÓÐʲô¹ØϵÄØ£¿¾ÍÄÃÊýѧ¿âÀ´Ëµ£¬ËûµÄ¿âÃûÊÇm£¬ËûµÄ¿âÎļþÃûÊÇlibm.so£¬ºÜÈÝÒ׿´³ö£¬°Ñ¿âÎļþÃûµÄÍ·libºÍβ.soÈ¥µô¾ÍÊÇ¿âÃûÁË¡£
ºÃÁËÏÖÔÚÎÒÃÇÖªµÀÔõôµÃµ½¿âÃûÁË£¬±ÈÈçÎÒÃÇ×ÔÒÑÒªÓõ½Ò»¸öµÚÈý·½ÌṩµÄ¿âÃû×Ö½Ðlibtest.so£¬ÄÇôÎÒÃÇÖ»Òª°Ñlibtest.so¿½±´µ½/usr/libÀ±àÒëʱ¼ÓÉÏ-ltest²ÎÊý£¬ÎÒÃǾÍÄÜÓÃÉÏlibtest.so¿âÁË£ ......

LinuxÏÂC/C++±àÒëÆ÷gccʹÓüò½é

1.gcc°üº¬µÄc/c++±àÒëÆ÷
gcc,ccÓëc++,g++
gccºÍccÊÇÒ»ÑùµÄ£¬c++ºÍg++ÊÇÒ»ÑùµÄ¡£Ò»°ãc³ÌÐò¾ÍÓÃgcc±àÒ룬c++³ÌÐò¾ÍÓÃg++±àÒë¡£
2.gccµÄ»ù±¾Ó÷¨
gcc test.c£ºÈç¹ûûÓÐÖ¸¶¨Êä³öµÄÎļþ£¬Ä¬ÈϽ«±àÒë³öÒ»¸öÃûΪa.outµÄ³ÌÐò
gcc test.c -o test£º-o²ÎÊýÓÃÀ´Ö¸¶¨Éú³ÉÄ¿±ê³ÌÐòµÄÃû×Ö£¬ÕâÑù½«±àÒë³öÒ»¸öÃûΪtestµÄ³ÌÐò¡£
3.Ϊʲô»á³öÏÖundefined reference to 'xxxxx'´íÎó£¿
Ê×ÏÈÕâÊÇÁ´½Ó´íÎ󣬲»ÊDZàÒë´íÎó£¬Ò²¾ÍÊÇ˵Èç¹ûÖ»ÓÐÕâ¸ö´íÎó£¬ËµÃ÷ÄãµÄ³ÌÐòÔ´Âë±¾ÉíûÓÐÎÊÌ⣬ÊÇÄãÓñàÒëÆ÷±àÒëʱ²ÎÊýÓõò»¶Ô£¬ÄãûÓÐÖ¸¶¨Á´½Ó³ÌÐòÒªÓõ½µÃ¿â£¬±ÈÈçÄãµÄ³ÌÐòÀïÓõ½ÁËһЩÊýѧº¯Êý£¬ÄÇôÄã¾ÍÒªÔÚ±àÒë²ÎÊýÀïÖ¸¶¨³ÌÐòÒªÁ´½ÓÊýѧ¿â£¬·½·¨ÊÇÔÚ±àÒëÃüÁîÐÐÀï¼ÓÈë-lm¡£
4.-l²ÎÊýºÍ-L²ÎÊý
-l²ÎÊý¾ÍÊÇÓÃÀ´Ö¸¶¨³ÌÐòÒªÁ´½ÓµÄ¿â£¬-l²ÎÊý½ô½ÓמÍÊÇ¿âÃû£¬ÄÇô¿âÃû¸úÕæÕýµÄ¿âÎļþÃûÓÐʲô¹ØϵÄØ£¿¾ÍÄÃÊýѧ¿âÀ´Ëµ£¬ËûµÄ¿âÃûÊÇm£¬ËûµÄ¿âÎļþÃûÊÇlibm.so£¬ºÜÈÝÒ׿´³ö£¬°Ñ¿âÎļþÃûµÄÍ·libºÍβ.soÈ¥µô¾ÍÊÇ¿âÃûÁË¡£
ºÃÁËÏÖÔÚÎÒÃÇÖªµÀÔõôµÃµ½¿âÃûÁË£¬±ÈÈçÎÒÃÇ×ÔÒÑÒªÓõ½Ò»¸öµÚÈý·½ÌṩµÄ¿âÃû×Ö½Ðlibtest.so£¬ÄÇôÎÒÃÇÖ»Òª°Ñlibtest.so¿½±´µ½/usr/libÀ±àÒëʱ¼ÓÉÏ-ltest²ÎÊý£¬ÎÒÃǾÍÄÜÓÃÉÏlibtest.so¿âÁË£ ......
×ܼǼÊý:969; ×ÜÒ³Êý:162; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³ [15] [16] [17] [18] 19 [20] [21] [22] [23] [24]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ