Results 1 to 2 of 2

Thread: undefined reference

  1. #1
    Join Date
    Mar 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default undefined reference

    Hi ,
    I am trying to call a member function of a class present in a header file(ApnCamera.h)
    ApnCamera.h
    Qt Code:
    1. class CApnCamera
    2. {
    3. public:
    4. CApnCamera();
    5. ~CApnCamera();
    6.  
    7. bool GetDeviceHandle( void *hCamera, char *CameraInfo );
    8.  
    9. bool InitDriver( unsigned long CamIdA,
    10. unsigned short CamIdB,
    11. unsigned long Option );
    12.  
    13. bool Expose( double Duration, bool Light );
    14.  
    15. }
    To copy to clipboard, switch view to plain text mode 
    ApnCamera.cpp
    Qt Code:
    1. CApnCamera::CApnCamera()
    2.  
    3. {
    4.  
    5. AltaDebugOutputString( "APOGEE.DLL - CApnCamera::CApnCamera()" );
    6.  
    7.  
    8.  
    9. m_pvtPlatformType = Apn_Platform_Unknown;
    10.  
    11. m_ApnSensorInfo = NULL;
    12.  
    13. }
    14.  
    15. CApnCamera::~CApnCamera()
    16.  
    17. {
    18.  
    19. AltaDebugOutputString( "APOGEE.DLL - CApnCamera::~CApnCamera()" );
    20.  
    21.  
    22.  
    23. if ( m_ApnSensorInfo != NULL )
    24.  
    25. {
    26.  
    27. delete m_ApnSensorInfo;
    28.  
    29. m_ApnSensorInfo = NULL;
    30.  
    31. CloseDriver();
    32. }
    33.  
    34. }
    35. bool CApnCamera::Expose( double Duration, bool Light )
    36.  
    37. {
    38.  
    39. unsigned long ExpTime;
    40.  
    41. unsigned short BitsPerPixel;
    42.  
    43. unsigned short UnbinnedRoiX;
    44.  
    45. unsigned short UnbinnedRoiY;
    46.  
    47. unsigned short PreRoiSkip, PostRoiSkip;
    48.  
    49. unsigned short PreRoiRows, PostRoiRows;
    50.  
    51. unsigned short PreRoiVBinning, PostRoiVBinning;
    52.  
    53.  
    54.  
    55. unsigned short RegVal;
    56.  
    57. unsigned short RoiRegBuffer[15];
    58.  
    59. unsigned short RoiRegData[15];
    60.  
    61.  
    62.  
    63. unsigned short TotalHPixels;
    64.  
    65. unsigned short TotalVPixels;
    66.  
    67.  
    68.  
    69. unsigned long TestImageSize;
    70.  
    71.  
    72.  
    73. unsigned long WaitCounter;
    74.  
    75.  
    76.  
    77. char szOutputText[128];
    78. UnbinnedRoiY = m_pvtRoiPixelsV * m_pvtRoiBinningV;
    79.  
    80.  
    81.  
    82. PreRoiRows = m_ApnSensorInfo->m_UnderscanRows +
    83.  
    84. m_pvtRoiStartY;
    85.  
    86.  
    87.  
    88. PostRoiRows = m_ApnSensorInfo->m_TotalRows -
    89.  
    90. PreRoiRows -
    91.  
    92. UnbinnedRoiY;
    93.  
    94.  
    95.  
    96. TotalVPixels = UnbinnedRoiY + PreRoiRows + PostRoiRows;
    97.  
    98.  
    99. // Program the horizontal settings
    100.  
    101. RoiRegBuffer[1] = FPGA_REG_PREROI_SKIP_COUNT;
    102.  
    103. RoiRegData[1] = PreRoiSkip;
    104.  
    105.  
    106.  
    107. RoiRegBuffer[2] = FPGA_REG_ROI_COUNT;
    108.  
    109.  
    110.  
    111. // Number of ROI pixels. Adjust the 12bit operation here to account for an extra
    112.  
    113. // 10 pixel shift as a result of the A/D conversion.
    114.  
    115. if ( m_pvtDataBits == Apn_Resolution_SixteenBit )
    116.  
    117. {
    118.  
    119. RoiRegData[2] = m_pvtExposurePixelsH + 1;
    120.  
    121. }
    122.  
    123. else if ( m_pvtDataBits == Apn_Resolution_TwelveBit )
    124.  
    125. {
    126.  
    127. RoiRegData[2] = m_pvtExposurePixelsH + 12;
    128.  
    129. }
    130.  
    131.  
    132.  
    133. RoiRegBuffer[3] = FPGA_REG_POSTROI_SKIP_COUNT;
    134.  
    135. RoiRegData[3] = PostRoiSkip;
    136.  
    137.  
    138.  
    139. // Program the vertical settings
    140.  
    141. if ( m_pvtFirmwareVersion < 11 )
    142.  
    143. {
    144.  
    145. RoiRegBuffer[4] = FPGA_REG_A1_ROW_COUNT;
    146.  
    147. RoiRegData[4] = PreRoiRows;
    148.  
    149. RoiRegBuffer[5] = FPGA_REG_A1_VBINNING;
    150.  
    151. RoiRegData[5] = PreRoiVBinning;
    152.  
    153.  
    154.  
    155. RoiRegBuffer[6] = FPGA_REG_A2_ROW_COUNT;
    156.  
    157. RoiRegData[6] = m_pvtRoiPixelsV;
    158.  
    159. RoiRegBuffer[7] = FPGA_REG_A2_VBINNING;
    160.  
    161. RoiRegData[7] = (m_pvtRoiBinningV | FPGA_BIT_ARRAY_DIGITIZE);
    162.  
    163.  
    164.  
    165. RoiRegBuffer[8] = FPGA_REG_A3_ROW_COUNT;
    166.  
    167. RoiRegData[8] = PostRoiRows;
    168.  
    169. RoiRegBuffer[9] = FPGA_REG_A3_VBINNING;
    170.  
    171. RoiRegData[9] = PostRoiVBinning;
    172.  
    173.  
    174.  
    175. RoiRegBuffer[10] = FPGA_REG_SCRATCH;
    176.  
    177. RoiRegData[10] = 0;
    178.  
    179. RoiRegBuffer[11] = FPGA_REG_SCRATCH;
    180.  
    181. RoiRegData[11] = 0;
    182.  
    183. RoiRegBuffer[12] = FPGA_REG_SCRATCH;
    184.  
    185. RoiRegData[12] = 0;
    186.  
    187. RoiRegBuffer[13] = FPGA_REG_SCRATCH;
    188.  
    189. RoiRegData[13] = 0;
    190.  
    191. }
    192.  
    193. else
    194.  
    195. {
    196.  
    197. if ( m_ApnSensorInfo->m_EnableSingleRowOffset )
    198.  
    199. {
    200.  
    201. RoiRegBuffer[4] = FPGA_REG_A1_ROW_COUNT;
    202.  
    203. RoiRegData[4] = 0;
    204.  
    205. RoiRegBuffer[5] = FPGA_REG_A1_VBINNING;
    206.  
    207. RoiRegData[5] = 0;
    208.  
    209.  
    210.  
    211. RoiRegBuffer[6] = FPGA_REG_A2_ROW_COUNT;
    212.  
    213. RoiRegData[6] = PreRoiRows;
    214.  
    215. RoiRegBuffer[7] = FPGA_REG_A2_VBINNING;
    216.  
    217. RoiRegData[7] = PreRoiVBinning;
    218.  
    219.  
    220.  
    221. RoiRegBuffer[8] = FPGA_REG_A3_ROW_COUNT;
    222.  
    223. RoiRegData[8] = m_pvtRoiPixelsV;
    224.  
    225. RoiRegBuffer[9] = FPGA_REG_A3_VBINNING;
    226.  
    227. RoiRegData[9] = (m_pvtRoiBinningV | FPGA_BIT_ARRAY_DIGITIZE);
    228.  
    229.  
    230.  
    231. RoiRegBuffer[10] = FPGA_REG_A4_ROW_COUNT;
    232.  
    233. RoiRegData[10] = 0;
    234.  
    235. RoiRegBuffer[11] = FPGA_REG_A4_VBINNING;
    236.  
    237. RoiRegData[11] = 0;
    238.  
    239.  
    240.  
    241. RoiRegBuffer[12] = FPGA_REG_A5_ROW_COUNT;
    242.  
    243. RoiRegData[12] = PostRoiRows;
    244.  
    245. RoiRegBuffer[13] = FPGA_REG_A5_VBINNING;
    246.  
    247. RoiRegData[13] = PostRoiVBinning;
    248.  
    249. }
    250.  
    251. else
    252.  
    253. {
    254.  
    255. if ( PreRoiRows > 70 )
    256.  
    257. {
    258.  
    259. RoiRegBuffer[4] = FPGA_REG_A1_ROW_COUNT;
    260.  
    261. RoiRegData[4] = 1;
    262.  
    263. RoiRegBuffer[5] = FPGA_REG_A1_VBINNING;
    264.  
    265. RoiRegData[5] = (PreRoiRows-70);
    266.  
    267.  
    268.  
    269. RoiRegBuffer[6] = FPGA_REG_A2_ROW_COUNT;
    270.  
    271. RoiRegData[6] = 70;
    272.  
    273. RoiRegBuffer[7] = FPGA_REG_A2_VBINNING;
    274.  
    275. RoiRegData[7] = 1;
    276.  
    277. }
    278.  
    279. else
    280.  
    281. {
    282.  
    283. RoiRegBuffer[4] = FPGA_REG_A1_ROW_COUNT;
    284.  
    285. RoiRegData[4] = 0;
    286.  
    287. RoiRegBuffer[5] = FPGA_REG_A1_VBINNING;
    288.  
    289. RoiRegData[5] = 0;
    290.  
    291.  
    292.  
    293. RoiRegBuffer[6] = FPGA_REG_A2_ROW_COUNT;
    294.  
    295. RoiRegData[6] = PreRoiRows;
    296.  
    297. RoiRegBuffer[7] = FPGA_REG_A2_VBINNING;
    298.  
    299. RoiRegData[7] = PreRoiVBinning;
    300.  
    301. }
    302.  
    303.  
    304.  
    305. RoiRegBuffer[8] = FPGA_REG_A3_ROW_COUNT;
    306.  
    307. RoiRegData[8] = m_pvtRoiPixelsV;
    308.  
    309. RoiRegBuffer[9] = FPGA_REG_A3_VBINNING;
    310.  
    311. RoiRegData[9] = (m_pvtRoiBinningV | FPGA_BIT_ARRAY_DIGITIZE);
    312.  
    313.  
    314.  
    315. if ( PostRoiRows > 70 )
    316.  
    317. {
    318.  
    319. RoiRegBuffer[10] = FPGA_REG_A4_ROW_COUNT;
    320.  
    321. RoiRegData[10] = 1;
    322.  
    323. RoiRegBuffer[11] = FPGA_REG_A4_VBINNING;
    324.  
    325. RoiRegData[11] = (PostRoiRows-70);
    326.  
    327.  
    328.  
    329. RoiRegBuffer[12] = FPGA_REG_A5_ROW_COUNT;
    330.  
    331. RoiRegData[12] = 70;
    332.  
    333. RoiRegBuffer[13] = FPGA_REG_A5_VBINNING;
    334.  
    335. RoiRegData[13] = 1;
    336.  
    337. }
    338.  
    339. else
    340.  
    341. {
    342.  
    343. RoiRegBuffer[10] = FPGA_REG_A4_ROW_COUNT;
    344.  
    345. RoiRegData[10] = 0;
    346.  
    347. RoiRegBuffer[11] = FPGA_REG_A4_VBINNING;
    348.  
    349. RoiRegData[11] = 0;
    350.  
    351.  
    352.  
    353. RoiRegBuffer[12] = FPGA_REG_A5_ROW_COUNT;
    354.  
    355. RoiRegData[12] = PostRoiRows;
    356.  
    357. RoiRegBuffer[13] = FPGA_REG_A5_VBINNING;
    358.  
    359. RoiRegData[13] = PostRoiVBinning;
    360.  
    361. }
    362.  
    363. }
    364.  
    365. }
    366.  
    367.  
    368.  
    369. // Issue the reset
    370.  
    371. RoiRegBuffer[14] = FPGA_REG_COMMAND_B;
    372.  
    373. RoiRegData[14] = FPGA_BIT_CMD_RESET;
    374.  
    375.  
    376.  
    377. // Send the instruction sequence to the camera
    378.  
    379. AltaDebugOutputString( "APOGEE.DLL - CApnCamera::Expose() -> Issue WriteMultiMRMD() for Exposure setup" );
    380.  
    381. WriteMultiMRMD( RoiRegBuffer, RoiRegData, 15 );
    382.  
    383.  
    384.  
    385. // Handle the IR PreFlash, if enabled
    386.  
    387. if ( m_pvtPreFlashEnable )
    388.  
    389. {
    390.  
    391. double strobeVal = read_ShutterStrobePosition();
    392.  
    393. double preflashVal = m_ApnSensorInfo->m_IRPreflashTime / 1000;
    394.  
    395.  
    396.  
    397. // v22 only
    398.  
    399. preflashVal = 110/1000;
    400.  
    401.  
    402.  
    403. write_ShutterStrobePosition( preflashVal );
    404.  
    405.  
    406.  
    407. // set the preflash bit
    408.  
    409. Read( FPGA_REG_OP_B, RegVal );
    410.  
    411. RegVal |= FPGA_BIT_IR_PREFLASH_ENABLE;
    412.  
    413. Write( FPGA_REG_OP_B, RegVal );
    414.  
    415.  
    416.  
    417. // dark frame duration is based on our sensor's specified preflash time
    418.  
    419. TakeNoDataDarkExposure( preflashVal + 0.050 );
    420.  
    421.  
    422.  
    423. // set the preflash bit back to zero
    424.  
    425. Read( FPGA_REG_OP_B, RegVal );
    426.  
    427. RegVal &= ~FPGA_BIT_IR_PREFLASH_ENABLE;
    428.  
    429. Write( FPGA_REG_OP_B, RegVal );
    430.  
    431.  
    432.  
    433. // set our shutter strobe back
    434.  
    435. write_ShutterStrobePosition( strobeVal );
    436.  
    437.  
    438.  
    439. // Re-calculate the exposure time to program to the camera
    440.  
    441. ExpTime = ((unsigned long)(Duration / m_PlatformTimerResolution)) + m_PlatformTimerOffsetCount;
    442.  
    443.  
    444.  
    445. // reprogram the timer
    446.  
    447. Write( FPGA_REG_TIMER_LOWER, (unsigned short)(ExpTime & 0xFFFF));
    448.  
    449. ExpTime = ExpTime >> 16;
    450.  
    451. Write( FPGA_REG_TIMER_UPPER, (unsigned short)(ExpTime & 0xFFFF));
    452.  
    453.  
    454.  
    455. ResetSystemNoFlush();
    456.  
    457.  
    458.  
    459. // Send the instruction sequence to the camera
    460.  
    461. AltaDebugOutputString( "APOGEE.DLL - CApnCamera::Expose() -> Issue WriteMultiMRMD() for Exposure setup" );
    462.  
    463. WriteMultiMRMD( RoiRegBuffer, RoiRegData, 15 );
    464.  
    465. }
    466.  
    467.  
    468.  
    469. // Issue the flush for interlines, or if using the external shutter
    470.  
    471. if ( (m_ApnSensorInfo->m_InterlineCCD && m_pvtFastSequence) ||
    472.  
    473. (m_pvtExternalShutter) ||
    474.  
    475. (m_pvtTriggerNormalGroup) || (m_pvtTriggerTdiKineticsGroup) )
    476.  
    477. {
    478.  
    479. // Make absolutely certain that flushing starts first
    480.  
    481. // in order to use Progressive Scan/Ratio Mode
    482.  
    483. Write( FPGA_REG_COMMAND_A, FPGA_BIT_CMD_FLUSH );
    484.  
    485.  
    486.  
    487. for ( int i=0; i<2; i++ )
    488.  
    489. {
    490.  
    491. Write( FPGA_REG_SCRATCH, 0x8086 );
    492.  
    493. Write( FPGA_REG_SCRATCH, 0x8088 );
    494.  
    495. }
    496.  
    497. }
    498.  
    499.  
    500.  
    501. m_pvtExposureExternalShutter = m_pvtExternalShutter;
    502.  
    503.  
    504.  
    505. IssueExposeCommand( Light );
    506.  
    507.  
    508.  
    509. // Set our flags to mark the start of a new exposure
    510.  
    511. m_pvtImageInProgress = true;
    512.  
    513. m_pvtImageReady = false;
    514.  
    515.  
    516.  
    517. // Debug output for leaving this function
    518.  
    519. sprintf( szOutputText, "APOGEE.DLL - CApnCamera::Expose( Duration = %f, Light = %d ) -> END", Duration, Light );
    520.  
    521. AltaDebugOutputString( szOutputText );
    522.  
    523.  
    524.  
    525. return true;
    526.  
    527. }
    To copy to clipboard, switch view to plain text mode 

    ourcode.cpp
    Qt Code:
    1. #include <string.h>
    2. #include <stdio.h>
    3. #include <stdlib.h>
    4. #include"fitsio.h"
    5. #include<math.h>
    6. #include <unistd.h>
    7. #include <time.h>
    8. #include"tcl.h"
    9. #include"ApnCamera.h"
    10. double a;
    11. bool asd,cond;
    12.  
    13. namespace x
    14. {
    15. CApnCamera *al=(CApnCamera *)new CApnCamera();
    16. };
    17.  
    18. int main(int argc,char **argv)
    19. {
    20. a=0.5;
    21. cond=true;
    22. using namespace x;
    23. al->Expose(a,cond);
    24. if(asd)
    25. printf("Initialized Properly");
    26. delete al;
    27. }
    To copy to clipboard, switch view to plain text mode 
    When we execute we get the following error in Build Issues
    /home/subhash/testing-build-desktop/../testing/main.cpp:31: error: undefined reference to `CApnCamera::Expose(double, bool)'
    :: error: collect2: ld returned 1 exit status


    And in compile output we get
    main.o: In function `main':
    /home/subhash/testing-build-desktop/../testing/main.cpp:31: undefined reference to `CApnCamera::Expose(double, bool)'
    make: Leaving directory `/home/subhash/testing-build-desktop'
    collect2: ld returned 1 exit status
    make: *** [testing] Error 1
    The process "/usr/bin/make" exited with code %2.
    Error while building project testing (target: Desktop)
    When executing build step 'Make'

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: undefined reference

    Did ApnCamera.cpp get built?
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

Similar Threads

  1. undefined reference
    By digidas in forum Newbie
    Replies: 9
    Last Post: 19th May 2010, 14:04
  2. undefined reference
    By jayreddy in forum Qt Programming
    Replies: 1
    Last Post: 20th November 2009, 14:45
  3. Undefined reference to crt
    By derektaprell in forum Installation and Deployment
    Replies: 0
    Last Post: 20th October 2009, 09:34
  4. Undefined Reference To...
    By ManuMies in forum Qt Programming
    Replies: 6
    Last Post: 10th February 2009, 13:14
  5. Undefined reference
    By Salazaar in forum Newbie
    Replies: 12
    Last Post: 23rd May 2007, 11:21

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.