HOME - - - - - Lazarus Tutorials TOC - - - - - - Other material for programmers

Getting started with Synapse in Lazarus

Free programming environment. Free TCP/IP units.
And all multi-platform.

Getting started with Synapse in Lazarus.

In July 2022, I set out to do some TCP/IP stuff, having been away from it for a while.

Sigh... two fed flags... which I chose to igore: The site's SSL certificate was expired. And the latest edition of the libraries was "2012-04-24 New Synapse release 40". But it WAS SO GOOD when I used it before that I ignored these issues, and pressed on.

I reviewed my July 22 options, and decided that Synapse was still one of the best options. It is free, and works with Windows and Linux, for a sttart!

14 Feb 17, I went back to Synapse, having been away for a while. (I wasn't using a different package, I just hadn't been doing any TCP/IP programming for a while.)

I was using a freshly installed Lazarus version 1.6.2 (2016-11-12) on a 64-bit Windows 7 computer. (I have not had good luck with the 64 bit Lazarus in the past, and tend to use the 32-bit compiler. For a start, I want things I write to work on a variety of machines. I don't want to maintain two versions.)

It had a tab on the components bar "SynEdit" which is, I believe, nothing to do with the Synapse TCP/IP package. Ditto a tab "IPro". Both were present in a freshly installed Lazarus.

I don't think the computer concerned had ever had Synapse on it.

((Sidebar:)) Oddly enough, although I don't think this machine ever had Synapse on it, something I wrote a while ago (which uses Synapse) compiled quite happily on this "Synapse-less" machine. I believe this was because of the Synapse .pas files I had in the folder with the sourcecode for my project. There were 8 files in the folder which I believe came from Synapse. I say "came from"... I think I just used the ordinary Windows file handling utility to copy those files into the folder from... somewhere! (Another machine I'd installed Synapse on? (P.S.: No... it turns out I'd downloaded the package three years ago, in 2014. Apparently that time I just copied files from it. Didn't "install".)

Oh. Duh. RTFM'd (http://wiki.freepascal.org/Synapse#Installation) after I'd worried about the above for a while, and found...

Installation can be as simple as simply copying over all
files to your application directory and adding the relevant
Synapse units to your uses clause.

A more elegant and recommended way is compiling the
laz_synapse.lpk package so you can use the same units in
all your projects.

Oh well. Having used the first solution in the past, and found it a pain to figure out WHICH files were needed, I thought that this time I'd try the alternative. (Figuring out which files are needed is a funny thing... An error message will say you need file "x". So you copy that to the project folder, and try to compile again. But file "x" needs files "y" and "z". So you copy them. And...

But the first DOES work. (You just have to deal with a number of "Could not find such-and-such file" complaints... once per project.)

So I set off to conquer the second approach. I got it working... sort of. You now tell it where to look for the "missing" files (the .pas files supplied by Synapse) in the Project/ Project Options page. there must be a way to tell your Lazarus that you want that particular folder ((MyDocs)\Lazarus\ThirdPtry\Synapse\source\lib, if you set things up as I did) in YOUR default project options. I haven't found it yet. But it is worth using the "set Lazarus to look in the extra place" trick! The only downside is that an archive of the project won't include ALL of the files used to compile it. If the archive is moved to another machine, besides setting up Lazarus, the Synapse .pas files that project uses will also have to be made available. (I don't think this is a deal breaker.)

((end sidebar))

Much against my general wish for the quiet life, for you, dear reader, I embarked upon a Lazarus update prior to starting the Synapse tutorial I sat down to write. See my account of how the update went, if the information is of interest.

Install Synapse

Happy discovery!... Synapse not only gives you access to TCP/IP, but I think it has some stuff for using the computer's serial port. Not sure if that includes simulated serial, as provided by some USB devices. (If Synapse doesn't offer this, a package with serial support is available from the same source. (See the download page.)

Just before we start, with the hope that I can put you in the right frame of mind: Here's a useful and informative note from the official Synapse page on installing Synapse...

Synapse is NOT a set of components. It is only library of units with
code and classes. It cannot be installed, it does not need to be
installed! To use Synapse, you simply copy all the necessary Synapse
units to your project directory (or to your library search path) and
in your project add a USES line listing the needed Synapse units.

Went to the Synapse homepage.

Slightly worrying... the most recent (at 14 Feb 17) latest full release was from 2012. And there was talk about the program needing a Win 32 operating system. The latter not, I hope, an issue for me, because I use the 32-bit Lazarus, even on my 64-bit machine. But maybe it will matter to others?

Clicked "Download". It went VERY quickly... under three seconds on my rather slow connection... but I had a .zip file of 899kb. The download page said it included "demos and documentation"... and simple investigation, again with the normal Windows file management utility, made it seem that this was true.

Take a moment to read the short "README.txt" inside the distribution .zip.

Ha! Hoist by my own petard! Synapse "installs" the way my own software installs. No messing with the registry. No "click the magic button and it will all be done for you (how we want to do it.)"

So you have options. Here's how I "installed" the program on my system...

Start by setting up a temporary folder for the contents of the Synapse .zip file, and unzip everything into it.

I like to keep third party things where I can see them for what they are. I have, in "MyDocs", a "Lazarus" folder which is where I keep the sourcecode, etc, of my projects. (In sub-folders, one per project)

That seemed a good place to put the Synapse stuff. (I'd already learned from the README.txt file that there's a way to let Lazarus know where to look.)

So, I created (MyDocs)\Lazarus\ThirdPrty\Synapse

(I've learned that with software which is also happy on Macs and Linux, it is best to avoid spaces in names, and to remember that THisNAme and thisname are sometimes seen as DIFFERENT. (Which of course they are NOT in Windows.) So I try to be consistent about the case of letters in a name.)

It seemed best to put ALL of the Synapse files in one place. A shortcut to
can go where I want it, for every day access, in due course.

So... "Synapse installed"... but my Lazarus IDE doesn't yet know it!

Showing Lazarus where to find the Synase material

Fire up Lazarus.

I'm going to show you how I use third party materials... I only make them available on a project- by- project basis. Install them globally, and it is too easy to begin to think of something as part of the basic Lazarus. My view. There probably is a way to make something available "for all time"... but you'll have to look elsewhere for that.

To say to Lazarus, "for this project, you should use..." you first go into a specific project. Either open an old one you want to extend, or start a new one.

Use "Project/ Project Options/ Compiler Options/ Paths/.."

Once you've gone that far, there will be a panel to the right, with multiple edit boxes.

If you "installed" Synapse on your system as described earlier... i.e. unzipped all they offer, someplace sensible, but haven't made those files GENERALLY available to your Lazarus work, then you continue as follows. (If you haven't, go back and do that!)

Click the ellipsis (...) to the right of the edit box for "Other Unit Files (-Fu):", and the "Path Editor" should open. (That name is in title bar.)

Click the folder icon.


Drill to the relevant folder... in this case ...\Synapse\source\lib. Click Add. Click Test. Click OK.

Using ver 1.6.2 on a Win 7 machine, Oct 17, I have to admit, my Lazarus was a bit flaky while I was trying to do this... especially if I clicked the "Test" button... it didn't crash when I hit "Test", but it did shortly after, and then during the next re-launch, and THEN it settled down.

16 Jul 22, Win 10, Laz 2.0.0: It Just Worked! (^_^)

I like it!! (It is at the core of some of the apps that are most important to me, apps that have worked well for YEARS, at 2022.)


Once Lazarus can find the Synapse .pas files it needs, try running some of the examples which come with Synapse... or go straight to some of my tutorials.

   Search this site or the web        powered by FreeFind
  Site search Web search
Site Map    What's New    Search   BEWARE: There is stuff at my other two sites that the search above won't reveal. Go to either site (see links below) and use that site's FreeFind search button.

BEWARE: The search above only visits a selection of my stuff. Go to either of my other sites (see links below) and use that site's FreeFind search button, if you haven't found something you "know is there".

In addition to the tutorials for which this page serves as Table of Contents, I have other sites with material you might find useful.....

My other sites....
Sheepdog Software homepage.
My Arunet homepage.

... and some links to specific pages within them you might want....
You can't "play" all day... learn to use the Libre Office/ Open Office database. Free. Multi-platform.
The Arduino- LOTS of fun, for not much money. And beginner (intelligent beginner) friendly. And good pursuit for kids. Combine programming and electronics!
Designing printed circuit boards the KiCad way. Free. Multi-platform. Long established. PCB-fab houses take native KiCad files.
And lastly... Making maps... how we did it before GPS Indulge me? This discusses a worthwhile, fun (if presented intelligently) activity for kids, which can be undertaken on many levels... a simple 20 minutes, or weeks of engaging activity. (Also known to divert susceptible adults.)

Ad from page's editor: Yes.. I do enjoy compiling these things for you... hope they are helpful. However.. this doesn't pay my bills!!! If you find this stuff useful, please at least help me with Facebook links, etc (buttons at top of page). If you run an MS-DOS or Windows PC, please visit my freeware and shareware page, try something? Links on your page to this page would also be appreciated, of course!
Click here to visit editor's freeware, shareware page.

   Here is the way to contact the author of these Lazarus/Delphi tutorials, Tom Boyd.

Valid HTML 4.01 Transitional Page WILL BE tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at validator.w3.org. (Mostly passes. A few problems caused by Google+ and Delicious code.)

If this page causes a script to run, why? Because of things like Google panels, and the code for the search button. Why do I mention scripts? Be sure you know all you need to about spyware.

....... P a g e . . . E n d s .....