Can't find the user library when compiling

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

Post Reply
Aresby
Posts: 64
Joined: Fri Mar 16, 2012 8:35 am
Location: Milton Keynes, UK
Contact:

Can't find the user library when compiling

Post by Aresby » Wed Mar 28, 2012 4:27 pm

I've bumped this from an old thread I hijacked as I guess no one is looking at it any more.

David Barker wrote:
Compile will search for modules in the following order..

(a) in the folder that contains the main program
(b) the user library folder
(c) the system library folder
I've had to move the default SW folders elsewhere on my PC so I can share them with my other PC.

The impact is that, although I kept the same folder structure, and have told Swordfish where the (top level) Default Startup Source Folder is, it cannot find my User Library folder at the same level. It can't find the library file even if I point SW at that user library folder as the start-up folder.

The end result is that my library files are now scattered amongst my user files, which is obviously not the best (nor the intended) way of working.

I don't want to continue in this way and would ideally like to have several user libraries (or sub folders within that top folder) so that I can organise my files logically.

Do I need to add a path to the environment, would that help the search?
Aresby
Swordfish & PIC Newbie

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Post by David Barker » Thu Mar 29, 2012 8:04 am

I'm not what I can add other that what's been said before.
Compile will search for modules in the following order..

(a) in the folder that contains the main program
(b) the user library folder
(c) the system library folder
You cannot relocate the 'library' or 'userlibrary' folders - they have to be located in a specific location for the compiler to find them. You can of course create sub-folders within the 'library' and 'userlibrary' folders.

Aresby
Posts: 64
Joined: Fri Mar 16, 2012 8:35 am
Location: Milton Keynes, UK
Contact:

Post by Aresby » Thu Mar 29, 2012 4:08 pm

When you "cannot be relocated" I guess you mean that Swordfish doesn't currently support that feature :)

How about considering this a formal request to allow it to be user-defined, in exactly the same way that you allow the default startup folder to be defined in the View, Editor Options?

I'd even be grateful for allowing the UserLibrary to be a sub-folder of the default startup folder - just so I can let DropBox find it and move stuff about between PCs?

Any chance of this happening, David? Please?

(If I need to request enhancements to SW via a different route then please do let me know).
Aresby
Swordfish & PIC Newbie

Jerry Messina
Swordfish Developer
Posts: 1473
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Post by Jerry Messina » Thu Mar 29, 2012 6:58 pm

As you've found out, Swordfish doesn't really support using user-assigned folders and paths other than the standard ones. There's not really any path you can change. I could be wrong (since I don't use that feature), but I think the Default Source Folder you're talking about is purely for the editor 'file open' and 'save as' dialogs.

FWIW, here's what I do (this works under XP... don't know about Win7). Some folks would hate this method, I'm sure, but it works for me.

Under my main project folder I create subdirectories to hold all my library files. So that I can get a complete archive of my project along with all of the libraries it was compiled with, I actually don't use the standard library folders at all. If I use a "standard" library, I actually put a local copy of the file into my project userlib folder. It can make library updates a bit of a pain to manage, but that way I know that I can always go back and fully re-create each version of a project no matter what changes may have been made to the SF libraries. It works sort of as a poor man's version control system.

So, I end up with a structure something like this:

Code: Select all

ProjectXYZ
	main.bas
	file1.bas
	file2.bas
	userlib
		fileA.bas
		fileB.bas
		<modified copies of SF standard libraries>
		convert.bas
		math.bas
	netlib
		fileC.bas
		fileD.bas
	usblib
		fileE.bas
In each of my files, I include the path to the desired file...

Code: Select all

file main.bas:
	include "userlib/fileA.bas"
	include "userlib/fileB.bas"
	include "netlib/fileC.bas"
	include "usblib/fileE.bas"
	include "userlib/math.bas"
	include "file1.bas"
	include "file2.bas"

file file1.bas:
	include "userlib/fileA.bas"
	include "netlib/fileC.bas"
	include "usblib/fileE.bas"
	include "file2.bas"
	
file file2.bas:
	include "userlib/fileA.bas"

file userlib\fileA.bas:
	include "userlib/fileB.bas"
	include "userlib/fileC.bas"
	include "userlib/convert.bas"

file netlib\fileC.bas:
	include "netlib/fileD.bas"
	include "userlib/convert.bas"
I make sure that all of the 'include' statements in my library files have a path in them so that they don't ever default to the standard SF ones.

So, I guess it sort of defeats the purpose of a library since each project has its own. As I say, if you find a bug in a library this can be a bit of a pain to correct since the bug's now in multiple project's copies. I'm more concerned with version control, and for me this works easier than archiving the compiler with each project/version since all I need to do is copy the project subdirectory and I get all the required files.

When I start a new project, I just copy the folders from one of my other similar projects into the new project subdirectory.

Aresby
Posts: 64
Joined: Fri Mar 16, 2012 8:35 am
Location: Milton Keynes, UK
Contact:

Post by Aresby » Thu Mar 29, 2012 7:18 pm

Thanks for that detailed suggestion, Jerry.

It almost works for me. It would totally work if I could give a relative file path to the include files, or an absolute file path. So something like include "..\myLibrary\SomeFolder\utils.bas" or "c:\dropbox\myLibarary.utils.bas" would solve my issue.

As it happens I can only include "library" files subordinate to each program file; as you clearly point out to me, that means multiple copies of library files which is EXACTLY the problem I have after even this short period of using SW. It seems such a simple thing to provide in an IDE (and, dare I say it, "other" compilers allow this as a matter of course).

I just know that if I follow your example things will rapidly get out of hand and I won't know which library contains my most recent updates to, say, "USART.bas".

I've tried to do this every which way without getting in a total mess, or worse still, making a change on one PC and then not having that updated version available on the other. Hence my use of DropBox which synchronises everything beautifully - when it's in the DropBox folder of course!

I'm counting on David to at least consider this simple request - it's not even a compiler change, it's an environmental/IDE change! (Psst! You don't have influence in that area, do you? :wink:)
Aresby
Swordfish & PIC Newbie

User avatar
RangerBob
Posts: 152
Joined: Thu May 31, 2007 8:52 am
Location: Beds, UK

Re: Can't find the user library when compiling

Post by RangerBob » Fri Mar 30, 2012 9:57 am

Perhaps you are approaching this problem from the wrong direction.

There are ways of making dropbox synchonise things outside its own folder by using Symbolic Links (search "symbolic link dropbox").

** WARNING ** EDITED: (I got it backwards!)
For example on Windows 7:

You need to move your "Swordfish" folder (C:\Users\Steve\Documents\Swordfish) into dropbox. (Back it up first too!)

You then need to run an administrator CMD window:
mklink /D "C:\Users\Steve\Documents\Swordfish" "C:\Users\Steve\Dropbox\Swordfish"

This will recreate the directory called swordfish in your documents folder where Swordfish expects it, which contains your UserLibrary, samples and your default saves.

It has to be moved into dropbox for dropbox to see the changes (dropbox can't see the changes from the symlink if its the other way round).
Swordfish just sees the symlinked folder as a normal folder and doesn't care; it can work with the files, they just don't really exist there.

Hope this helps,

Rangerbob

PS. I use this method for a lot of programs, It makes Dropbox insanely powerful!

Aresby
Posts: 64
Joined: Fri Mar 16, 2012 8:35 am
Location: Milton Keynes, UK
Contact:

Elegant solution - just don't ask me to do it again!

Post by Aresby » Fri Mar 30, 2012 7:04 pm

@RangerBob

I did what you suggested; once on my Windows 7 PC which has the mklink utility you mentioned as standard.

Then I had to do it all again on my XP machine after downloading the "junction" utility from here:

http://technet.microsoft.com/en-us/sysi ... 96768.aspx

The syntax is much the same (it's all explained on that page). Effectively it's the XP equivalent of the mklink utility included with Win 7.

Of course, if only it were all that simple. What with an old installation of SwordfishSE, and now the full blown compiler, all with different libraries and locations it took about 3 hours to sort out my PCs and finally consider it completed!

But thank you very much; this is exactly the solution I needed. I'm almost tempted to write an article explaining how to do it in both Win7 and XP whilst it's fresh in my mind for the other poor critters who stumble upon this post in future years! If I do I'll nudge David to see whether it's worthy of inclusion somewhere either on this site or the Mechanique site.

And, as you so rightly say, this is not specific to Swordfish; it can be used for any folder on your PC.

Brilliant! :P
Aresby
Swordfish & PIC Newbie

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Post by David Barker » Sat Mar 31, 2012 8:42 am

Write an article and post it here:

http://www.wiki.sfcompiler.co.uk/

Aresby
Posts: 64
Joined: Fri Mar 16, 2012 8:35 am
Location: Milton Keynes, UK
Contact:

Post by Aresby » Sun Apr 01, 2012 2:06 pm

OK, David, you've talked me round.

I've written it, got the XP part of it validated by none other than our very own Jerry Messina and have double checked the Windows 7 part (which although I had to carry out myself, was before the article was written so may contain unclear parts).

Can be found under "Using Dropbox with Swordfish" in the usual list of articles http://www.sfcompiler.co.uk/wiki/pmwiki ... r.Articles which I took the liberty of adding to - if I needed to get your nod of approval please forgive my being forward.

If anyone else uses the article and finds parts that are unclear or just plain wrong then feel free to let me know and I'll correct it.

Full credit must also be given to RangerBox who set me on this trail and who has thereby facilitated making Swordfish (and, indeed Dropbox) even more fantastic than they already were!
Aresby
Swordfish & PIC Newbie

Post Reply