- 論壇徽章:
- 0
|
呵呵,wget和curl,axel這種工具,最終會生成一個提供給用戶的Exe
但是,不可避免會有多個main,因為有些是用于測試的,比如axel中search.c中就是這樣的,但是他們是一般是不會與Axel的main沖突的,因為search.c中的main是用宏定義來聲明的,要不然的話,如果.o鏈接進text.o中,編譯器會報錯的,多個main。
另外一點就是,確實是想編譯多個工具,但是這多個c文件生成的.o文件是不會link到一起的。
樓主不妨按照我說的第一點去分析下不同main函數(shù)的作用,找找define宏是干啥的。
比如axel的search.c中這個
- #ifdef STANDALONE
- int main( int argc, char *argv[] )
- {
- conf_t conf[1];
- search_t *res;
- int i, j;
-
- if( argc != 2 )
- {
- fprintf( stderr, "Incorrect amount of arguments\n" );
- return( 1 );
- }
-
- conf_init( conf );
-
- res = malloc( sizeof( search_t ) * ( conf->search_amount + 1 ) );
- memset( res, 0, sizeof( search_t ) * ( conf->search_amount + 1 ) );
- res->conf = conf;
-
- i = search_makelist( res, argv[1] );
- if( i == -1 )
- {
- fprintf( stderr, "File not found\n" );
- return( 1 );
- }
- printf( "%i usable mirrors:\n", search_getspeeds( res, i ) );
- search_sortlist( res, i );
- for( j = 0; j < i; j ++ )
- printf( "%-70.70s %5i\n", res[j].url, res[j].speed );
-
- return( 0 );
- }
- #endif
復(fù)制代碼 |
|