[問題] 有關ALGLIB函式庫

看板C_and_CPP作者 (043)時間13年前 (2012/09/04 01:25), 編輯推噓1(103)
留言4則, 3人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) Dev C++ 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) ALGLIB函式 問題(Question): 小弟初學C++,若問了笨問題請多包含 我目前想在主程式中使用卡方分布的函式 因此在網路上搜尋,下載了ALGLIB的標頭檔,丟入該編譯器的include資料夾進行呼叫 (http://www.alglib.net/download.php) 但編譯時總是出現linker error, 用此關鍵字查詢版上舊文的方法也無法成功 在網站上,則有以下描述: If you use modern versions of MSVC, GCC or Sun Studio, you don't need to configure ALGLIB at all. But if you use outdated versions of these compilers (or something else), then you may need to tune definitions of several data types: alglib_impl::ae_int32_t - signed integer which is 32 bits wide alglib_impl::ae_int64_t - signed integer which is 64 bits wide alglib_impl::ae_int_t - signed integer which has same width as pointer ALGLIB tries to autodetect your compiler and to define these types in compiler-specific manner: ae_int32_t is defined as int, because this type is 32 bits wide in all modern compilers. ae_int64_t is defined as _int64 (MSVC) or as signed long long (GCC, Sun Studio). ae_int_t is defined as ptrdiff_t. In most cases, it is enough. But if anything goes wrong, you have several options: 接著這段不知道是不是重點 if your compiler provides stdint.h, you can define AE_HAVE_STDINT conditional symbol alternatively, you can manually define AE_INT32_T and/or AE_INT64_T and/or AE_INT_T symbols. Just assign datatype name to them, and ALGLIB will automatically use your definition. You can define only one or two types (those which are not defined automatically). 錯誤結果(Wrong Output): [Linker error] ....../4_GOF_test.o:4_GOF_test.cpp:(.text+0x31084): undefined reference to `alglib_impl::nulog1p(double, alglib_impl::ae_state*)' 程式碼(Code):(請善用置底文網頁, 記得排版) #include <iostream> #include "ap.h" #include "ap.cpp" #include "specialfunctions.h" #include "specialfunctions.cpp" int main() { std::cout << alglib::chisquaredistribution(3, 0.05); system("pause"); return 0; } 補充說明(Supplement): 若紅字部分正是問題所在 請問所謂define conditional symbol, 具體上要針對哪一個標頭檔? 又要寫入什麼呢? 懇請版上前輩解惑, 感謝! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.136.138.125 ※ 編輯: Typebrook 來自: 114.136.138.125 (09/04 01:26)

09/04 01:26, , 1F
link error與header檔沒有關係
09/04 01:26, 1F

09/04 05:11, , 2F
link 指令加 "-l"加程式庫名 ex. -lalglib
09/04 05:11, 2F
感謝回覆!! 不過ALGLIB並不提供 .a類型的檔案(我想link指令應該是要連結這個), 而是內含數個subpackage, 皆為.cpp和 .h檔 目前我找到類似的問題: http://forum.alglib.net/viewtopic.php?f=2&t=530 但我若將specialfunctions.cpp加入專案內,並維持原本的程式碼 則編譯時多了"multiple definition"的問題,還是無解 ※ 編輯: Typebrook 來自: 114.136.197.15 (09/04 07:59) ※ 編輯: Typebrook 來自: 114.136.197.15 (09/04 08:02)

09/04 08:06, , 3F
http://ppt.cc/LXOp 這是使用手冊
09/04 08:06, 3F

09/04 08:08, , 4F
我想重點應該在 2.3.1 和2.3.2的部分
09/04 08:08, 4F
文章代碼(AID): #1GHEVxca (C_and_CPP)