Recent

Author Topic: Building project and lots of undefined reference errors pop up, why?  (Read 1429 times)

BosseB

  • Sr. Member
  • ****
  • Posts: 295
I have been working on a project for a controller based on Raspberry Pi4 using Lazarus/FPC.
I am doing this natively on an RPi4 with Lazarus 2.0.6 and FPC 3.0.4.
The subproject I am on now is a webapp to be plugged into Apache2 as a cgi handler.
Everything has been working fine and I have built my webapp multiple times and plugged it into the apache cgi-bin dir for testing.

Now I have expanded a little bit on the internal webpage generation and wanted to test it.
But now when I build the app I get massive amounts of "undefined references" relating to units I don't even use! See below for an example!
The shown errors relate to the following units all of which I have no idea what they are, surely not part of my project at least!
Code: Text  [Select][+][-]
  1. wsmenus
  2. wscontrols
  3. wsforms
  4. wsstdctrls
  5. wsbuttons
  6. wsextctrls
  7. wscomctrls
  8. wsdialogs
  9. wsextdlgs

These units seem to be GUI oriented by looking at the names at least...

Note that my project is a No-GUI command line program, it is meant to be run by Apache as part of webpage generation!!!
Required packages are set to be indylaz and LCLBase (indylaz because I use source files which reference Indy components).

What can I do? I have tried to use these Run commands:
Quick Compile
Compile
Build
Clean up and build...

I have also set the widgetset to noGui even though that should not be needed for a command line program, right.
Nothing helps.

All ends in this mess of undefined references!

What can I do??? I don't even know what this ws... is in the first place.

Here is the error list:
Code: Text  [Select][+][-]
  1. Compile Project, Target: getwebpage: Exit code 1, Errors: 57, Hints: 1
  2. getwebpage.lpr(47,3) Note: Local variable "NumParm" is assigned but never used
  3. wsmenus.pp(263,1) Error: undefined reference to `WSRegisterMenu'
  4. wsmenus.pp(263,1) Error: undefined reference to `WSRegisterMainMenu'
  5. wsmenus.pp(263,1) Error: undefined reference to `WSRegisterPopupMenu'
  6. wscontrols.pp(508,1) Error: undefined reference to `WSRegisterLazAccessibleObject'
  7. wscontrols.pp(508,1) Error: undefined reference to `WSRegisterControl'
  8. wscontrols.pp(508,1) Error: undefined reference to `WSRegisterWinControl'
  9. wscontrols.pp(508,1) Error: undefined reference to `WSRegisterGraphicControl'
  10. wscontrols.pp(508,1) Error: undefined reference to `WSRegisterCustomControl'
  11. wsforms.pp(314,1) Error: undefined reference to `WSRegisterScrollBox'
  12. wsforms.pp(314,1) Error: undefined reference to `WSRegisterCustomFrame'
  13. wsforms.pp(314,1) Error: undefined reference to `WSRegisterCustomForm'
  14. wsforms.pp(314,1) Error: undefined reference to `WSRegisterHintWindow'
  15. wsstdctrls.pp(881,1) Error: undefined reference to `WSRegisterCustomGroupBox'
  16. wsstdctrls.pp(881,1) Error: undefined reference to `WSRegisterCustomComboBox'
  17. wsstdctrls.pp(881,1) Error: undefined reference to `WSRegisterCustomListBox'
  18. wsstdctrls.pp(881,1) Error: undefined reference to `WSRegisterCustomEdit'
  19. wsstdctrls.pp(881,1) Error: undefined reference to `WSRegisterCustomMemo'
  20. wsstdctrls.pp(881,1) Error: undefined reference to `WSRegisterButtonControl'
  21. wsstdctrls.pp(881,1) Error: undefined reference to `WSRegisterCustomButton'
  22. wsstdctrls.pp(881,1) Error: undefined reference to `WSRegisterCustomCheckBox'
  23. wsstdctrls.pp(881,1) Error: undefined reference to `WSRegisterToggleBox'
  24. wsstdctrls.pp(881,1) Error: undefined reference to `WSRegisterRadioButton'
  25. wsstdctrls.pp(881,1) Error: undefined reference to `WSRegisterCustomStaticText'
  26. wsstdctrls.pp(881,1) Error: undefined reference to `WSRegisterCustomLabel'
  27. wsbuttons.pp(119,1) Error: undefined reference to `WSRegisterCustomSpeedButton'
  28. wsextctrls.pp(346,1) Error: undefined reference to `WSRegisterCustomSplitter'
  29. wsextctrls.pp(346,1) Error: undefined reference to `WSRegisterPaintBox'
  30. wsextctrls.pp(346,1) Error: undefined reference to `WSRegisterCustomImage'
  31. wsextctrls.pp(346,1) Error: undefined reference to `WSRegisterBevel'
  32. wsextctrls.pp(346,1) Error: undefined reference to `WSRegisterCustomRadioGroup'
  33. wsextctrls.pp(346,1) Error: undefined reference to `WSRegisterCustomCheckGroup'
  34. wsextctrls.pp(346,1) Error: undefined reference to `WSRegisterCustomLabeledEdit'
  35. wsextctrls.pp(346,1) Error: undefined reference to `WSRegisterCustomPanel'
  36. wsextctrls.pp(346,1) Error: undefined reference to `WSRegisterCustomTrayIcon'
  37. wscomctrls.pp(955,1) Error: undefined reference to `WSRegisterTabSheet'
  38. wscomctrls.pp(955,1) Error: undefined reference to `WSRegisterPageControl'
  39. wscomctrls.pp(955,1) Error: undefined reference to `WSRegisterCustomListView'
  40. wscomctrls.pp(955,1) Error: undefined reference to `WSRegisterCustomProgressBar'
  41. wscomctrls.pp(955,1) Error: undefined reference to `WSRegisterCustomUpDown'
  42. wscomctrls.pp(955,1) Error: undefined reference to `WSRegisterCustomToolButton'
  43. wscomctrls.pp(955,1) Error: undefined reference to `WSRegisterToolBar'
  44. wscomctrls.pp(955,1) Error: undefined reference to `WSRegisterCustomTrackBar'
  45. wscomctrls.pp(955,1) Error: undefined reference to `WSRegisterCustomTreeView'
  46. wsdialogs.pp(275,1) Error: undefined reference to `WSRegisterFileDialog'
  47. wsdialogs.pp(275,1) Error: undefined reference to `WSRegisterOpenDialog'
  48. wsdialogs.pp(275,1) Error: undefined reference to `WSRegisterSaveDialog'
  49. wsdialogs.pp(275,1) Error: undefined reference to `WSRegisterSelectDirectoryDialog'
  50. wsdialogs.pp(275,1) Error: undefined reference to `WSRegisterColorDialog'
  51. wsdialogs.pp(275,1) Error: undefined reference to `WSRegisterColorButton'
  52. wsdialogs.pp(275,1) Error: undefined reference to `WSRegisterFontDialog'
  53. wsextdlgs.pp(203,1) Error: undefined reference to `WSRegisterPreviewFileDialog'
  54. wsextdlgs.pp(203,1) Error: undefined reference to `WSRegisterOpenPictureDialog'
  55. wsextdlgs.pp(203,1) Error: undefined reference to `WSRegisterSavePictureDialog'
  56. wsextdlgs.pp(203,1) Error: undefined reference to `WSRegisterCalculatorDialog'
  57. wsextdlgs.pp(203,1) Error: undefined reference to `WSRegisterCalculatorForm'
  58. wsextdlgs.pp(203,1) Error: undefined reference to `WSRegisterCalendarDialog'
  59. getwebpage.lpr(106,53) Error: Error while linking
  60.  
--
Bo Berglund
Sweden

BosseB

  • Sr. Member
  • ****
  • Posts: 295
Re: Building project and lots of undefined reference errors pop up, why?
« Reply #1 on: February 01, 2020, 01:07:41 am »
Workaround...
I completely restructured some units such that those that used Indy would not be needed anymore.
Had to create two new units to hold the class definitions and such I needed.
After that was done the project built OK again.
I will probably have to revisit the issue later because the unit using Indy is crucial for the operations of the system. But right now I work on the config side of things where Indy is not needed.
--
Bo Berglund
Sweden

PascalDragon

  • Hero Member
  • *****
  • Posts: 2405
  • Compiler Developer
Re: Building project and lots of undefined reference errors pop up, why?
« Reply #2 on: February 01, 2020, 11:16:02 am »
It seems that the Indy package is currently configured in a way that it pulls in the LCL as well. You could try to disable the option Add Package Unit to Uses Clause (or similar) in the Indy package's settings (and make sure that the IndyLaz unit is removed from your project). Though I currently don't know whether the parts of Indy you want to use will pull in other parts of the LCL nevertheless.

Maybe you'll have to change to another protocol suite depending on your needs (e.g. Synapse or FPC's HTTP client).

BosseB

  • Sr. Member
  • ****
  • Posts: 295
Re: Building project and lots of undefined reference errors pop up, why?
« Reply #3 on: February 01, 2020, 12:07:05 pm »
Well, in this project I actually do NOT want indy involved at all.
But I need some classes from the communications unit, where indylaz is used due to the comm channel.
But the classes I need just define data structures and have no Indy connection.
So I created two new units to which I moved the two classes out of the comm unit.
Then I could use these in my project and I also set the comm unit uses to pull them in so the old functionality would remain there.
It was quite a struggle but when it was done my current webapp project builds without errors.

It is strange because I have used Indy many times before also in non-gui projects without any problems. But those were on Windows, maybe there is a difference between Windows and Raspbian linux?
--
Bo Berglund
Sweden

PascalDragon

  • Hero Member
  • *****
  • Posts: 2405
  • Compiler Developer
Re: Building project and lots of undefined reference errors pop up, why?
« Reply #4 on: February 02, 2020, 04:05:30 pm »
Last time I used Indy was when I was still using Delphi myself. Where those non-gui projects with Lazarus or Delphi? If the later then there is the reason: Delphi simply pulls in the VCL without much fuzz, but in Lazarus that is separated more cleanly.

That said it's best to separate those code parts that rely on Indy into a separate unit anyway, cause of initialization sections and such in the Indy units the compiler might not be able to optimize everthing away and you'll carry around Indy code in your binary even if you don't use it.

 

TinyPortal © 2005-2018