- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear All,
My code need to call alt_busy_sleep(), but the compiler report the following error. Linking TestCPP.elf... obj/main.o(.gnu.linkonce.t._ZN13JaidTestClass18TestOSDBlockAdjustEv+0x18c): In function `JaidTestClass::TestOSDBlockAdjust()': C:/altera/OSD_FINAL/JaidNiosOSD/software/TestCPP/TestClass/TestClass.hpp:352: undefined reference to `alt_busy_sleep(unsigned int)' I have include the necessary header file in my code, # include "priv/alt_busy_sleep.h" also I can find alt_busy_sleep.c in C:\altera\kits\nios2_51\components\altera_nios2\HAL\src. Why the linker can't find alt_busy_sleep yet. Evenly I copy alt_busy_sleep.c to project folder, but the error still exist... Anybody help... Thanks in advance http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/laugh.gifLink Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- originally posted by david_cai@Jul 6 2006, 10:56 AM dear all,
my code need to call alt_busy_sleep(), but the compiler report the following error.
linking testcpp.elf...
obj/main.o(.gnu.linkonce.t._zn13jaidtestclass18testosdblockadjustev+0x18c): in function `jaidtestclass::testosdblockadjust()':
c:/altera/osd_final/jaidniososd/software/testcpp/testclass/testclass.hpp:352: undefined reference to `alt_busy_sleep(unsigned int)'
i have include the necessary header file in my code, # include "priv/alt_busy_sleep.h"
also i can find alt_busy_sleep.c in c:\altera\kits\nios2_51\components\altera_nios2\hal\src.
why the linker can't find alt_busy_sleep yet. evenly i copy alt_busy_sleep.c to project folder, but the error still exist...
anybody help...
thanks in advance http://forum.niosforum.com/work2/style_emoticons/<#emo_dir#>/laugh.gif
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=16681)
--- quote end ---
--- Quote End --- Hi David_Cai! I had this type of error when I had q5.1 and nios 5.0! Later I have installed Nios 5.1 and error had not occired. Please give more specific information about your system version of Q and Nios http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
nios2_5.1
quartusii_51_sp1_web_edition.exe somebody tell me that: Do you use C and C++ files in your project? You should declare the function alt_busy_sleep() is a C function if you use it in a C++ file. But I don't know how can I declare the function alt_busy_sleep() is a C function in C++ files. Also I need to understand why. Thanks for your reply....- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear All,
I have solved this issue. The answer is : declare the function alt_busy_sleep() is a C function if you use it in a C++ file extern "C" unsigned int alt_busy_sleep (unsigned int us); But I still don't know why... Anybody help? David- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi David
The compiler rules for C and C++ are some what differ. when you write any code in C and if you want to access that function or structure in C++ file then explicitly you have to tell to compiler and it will call that perticular function( or Build) as a C style rules and gives no error. At the same time you if you want to access C++ code in C file then also you have to define a Macro for that. Here i am passing you one link..Just go through this and get the detail answer. If you have any query then Ask me http://developers.sun.com/prodtech/cc/articles/mixing.html (http://developers.sun.com/prodtech/cc/articles/mixing.html) Best Regards, slsnios- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks very much...
I think that the basic reason is: The function name after compilation is different in C from that in C++. The declaration is necessary for both sides.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page