file Building with Linux

1 month 3 weeks ago #6425 by jvalenzuela
I've been working on a module that was started in Windows, and am now trying to move to Linux. The project has always built fine in Windows, but I get the following error when attempting to build in Linux:
java.lang.UnsatisfiedLinkError: 
Could not load SWT library. Reasons: 
no swt-win32-4924r25 in java.library.path
no swt-win32 in java.library.path
Can't load library: /home/jason/.swt/lib/linux/x86_64/libswt-win32-4924r25.so
Can't load library: /home/jason/.swt/lib/linux/x86_64/libswt-win32.so

I have swt installed as far as I can tell. What is strange is it appears to be looking for a win32 SWT, which of course wouldn't apply on a Linux system.

If it's relevant, I'm using xubuntu 20.04.2, Eclipse 2021-06(both Linux and Windows).

Thank you,
Jason Valenzuela

Please Log in or Create an account to join the conversation.

1 month 3 weeks ago #6426 by ffe
Hi Jason Valenzuela,

All the librairies necessary for building Modelio with Maven are stored in the Modelio/dev-platform/rcp-target/ directory.

* Have you followed the steps in the page: github.com/ModelioOpenSource/Modelio/wiki/Package_modelio ?
* Did you try the 'mvn clean' command before to execute the 'mvn package' command ?

Best regards,

Please Log in or Create an account to join the conversation.

1 month 3 weeks ago #6428 by jvalenzuela
The project in question is actually a module, not Modelio itself.

Please Log in or Create an account to join the conversation.

1 month 3 weeks ago #6429 by jvalenzuela
Some more information. As a quick and easy test I created a new module project with my Linux system, following the Wiki instructions, and it builds fine. The problem with the actual module project is with the unit tests, which use JUnit and Mockito to mock up various model objects. All this works fine in Windows 7 x64, but the same unit tests fail when building in Linux due to this SWT library.

I admit complete ignorance of Maven, and therefore this may not be the problem, but the MDAKit POM lists two SWT dependencies:
  • org.eclipse.swt
  • org.eclipse.swt.win32.win32.x86_64
Should the Windows-specific dependency be listed in this, presumably, platform-independent file?

Thank you,
Jason Valenzuela

Please Log in or Create an account to join the conversation.

1 month 2 weeks ago #6430 by jvalenzuela
I was able to isolate the problem, which is the lack of the correct platform SWT dependency in the MDAKit POM file.

As mentioned earlier, this project uses JUnit and Mockito for unit testing. The latter generates mock module context and modeling session objects to support services needed by the code being tested, such as IModelingSession.findByRef(). The unit tests do not have any UI, as is typical for unit tests, but I suspect something in the IModuleContext or IModelingSession needs SWT, and therefore fails when Mockito attempts to create a mock for it.

Making the following modifications to the MDAKit-4.0.0.00.pom yielded a successful build on a Linux system:
                <!-- Comment out original SWT dependencies.
		<dependency>
			<groupId>org.modelio</groupId>
			<artifactId>org.eclipse.swt</artifactId>
			<version>3.110.0.v20190305-0602</version>
		</dependency>


		<dependency>
			<groupId>org.modelio</groupId>
			<artifactId>org.eclipse.swt.win32.win32.x86_64</artifactId>
			<version>3.110.0.v20190305-0602</version>
		</dependency>
                -->


<!-- Insert SWT dependencies, including GTK/Linux artifact. -->
<dependency>
    <groupId>org.eclipse.platform</groupId>
    <artifactId>org.eclipse.swt</artifactId>
    <version>3.116.100</version>
</dependency>

<dependency>
    <groupId>org.eclipse.platform</groupId>
    <artifactId>org.eclipse.swt.gtk.linux.x86_64</artifactId>
    <version>3.116.100</version>
</dependency>

Obviously, this is just a temporary hack to track down the core problem. I don't yet know enough about Maven and SWT to determine if a cross-platform solution is possible, but it would be nice if the MDAKit could support it.


Thank you,
Jason Valenzuela

Please Log in or Create an account to join the conversation.

1 month 2 weeks ago #6432 by jvalenzuela
I was able to find a solution by using OS-specific Maven profiles in the module pom.xml to include the appropriate SWT dependency. The changes are these:

Define the profiles, I only created Windows and Linux:
	<!-- profiles

	These profiles are intended to handle problems during unit testing
	due to the MDAKit declaring a Windows-specific SWT dependency.
	Unit tests employ mock objects, which require SWT at some level,
	even though the tests do not exercise any GUI functionality.
	These platform-specific profiles define the appropriate
	SWT jar to replace the one excluded from the MDAKit.
	-->
<profiles>
		<!--
		Include the correct Linux SWT dependency, replacing the Windows
		one excluded from the MDAKit.
		-->
		<profile>
			<id>linux</id>
			<activation>
				<os>
					<name>Linux</name>
				</os>
			</activation>
			<dependencies>
				<dependency>
					<groupId>org.eclipse.platform</groupId>
					<artifactId>org.eclipse.swt.gtk.linux.x86_64</artifactId>
					<version>3.110.0</version>
					<scope>provided</scope>
					<exclusions>
						<exclusion>
							<groupId>org.eclipse.platform</groupId>
							<artifactId>org.eclipse.swt</artifactId>
						</exclusion>
					</exclusions>
				</dependency>
			</dependencies>
		</profile>

		<!--
		Use the same SWT artifact excluded from the MDAKit when building
		in Windows.
		 -->
		<profile>
			<id>windows</id>
			<activation>
				<os>
					<family>windows</family>
				</os>
			</activation>
			<dependencies>
				<dependency>
					<groupId>org.modelio</groupId>
					<artifactId>org.eclipse.swt.win32.win32.x86_64</artifactId>
					<version>3.110.0.v20190305-0602</version>
					<scope>provided</scope>
				</dependency>
			</dependencies>
		</profile>
	</profiles>


Exclude the platform-specific SWT dependency from MDAKit:
		<!-- api modelio -->
		<dependency>
			<groupId>org.modelio</groupId>
			<artifactId>MDAKit</artifactId>
			<version>[4.0.0,4.0.1)</version>
			<type>pom</type>
			<scope>provided</scope>

			<!--
			This dependency does not work when running unit tests on Linux
			platforms. It is excluded here so the correct dependency can
			be added via OS-specific profiles.
			 -->
			<exclusions>
				<exclusion>
					<groupId>org.modelio</groupId>
					<artifactId>org.eclipse.swt.win32.win32.x86_64</artifactId>
				</exclusion>
			</exclusions>
		</dependency>

Please Log in or Create an account to join the conversation.

Moderators: tmachmaab
Time to create page: 0.041 seconds
^ Back to Top