I'm trying to use the /D parameter of the Inno Setup Command Line Compiler to choose which files should be included in my setup.
The code looks like the following:
#define MyAppName "MyApp"
#define MyAppVersion "1.0.0"
(....)
#define PHASE
[Setup]
AppVersion={#MyAppVersion}
(....)
[Files]
Source: "C:\temp\myfile.txt"; DestDir: "{app}";
#if PHASE == "test"
Source: "C:\temp\onlyInTestBuildNeeded.txt"; DestDir: "{app}";
#endif
I try to compile the script ISCC /DPHASE=test "D:\foo\bar.iss" but it seems to have no effect on my PHASE define.
So can anyone explain me what I'm doing wrong? I can't find any more information at the Inno Setup Help.
You overwrite PHASE in the .iss file with the line
#define PHASE
Delete that line or check it with #ifdef in order to define it only when it is not set via command line /D switch:
#ifndef PHASE
#define PHASE
#endif
Related
I would like to connect the mysql database using C in CodeBlocks
I downloaded MySQL Connector C 6.1
I added this below to my linker settings
I added this to Compiler in Search directories
I copied libmysql.dll to my project directory and /windows/system
I added #include "mysql.h" to my hello world example and tried to compile it.
#include <stdio.h>
#include <stdlib.h>
#include "mysql.h"
int main()
{
printf("Hello world!\n");
return 0;
}
When I try to compile it I get following errors:
cannot find -l-lmysqlpp
cannot find -l-lmysqlclient
I would be grateful for any help.
EDIT:
Let me upload my test_build_log.html file
-------------- Build: Debug in test (compiler: GNU GCC Compiler)---------------
gcc.exe -o bin\Debug\test.exe obj\Debug\main.o "C:\Program Files\MySQL\MySQL Connector C 6.1\lib\libmysql.lib" "C:\Program Files\MySQL\MySQL Connector C 6.1\lib\vs12\mysqlclient.lib" -l-lmysqlpp -l-lmysqlclient
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -l-lmysqlpp
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -l-lmysqlclient
collect2.exe: error: ld returned 1 exit status
cannot find -l-lmysqlpp
cannot find -l-lmysqlclient
These should be presented to the linker as:
-lmysqlpp
-lmysqlclient
The repeating -l switch indicates something wrong in your linker settings. Make sure there are no entries (including spaces or other hidden characters) in both link library an d Other linker options boxes. You may need to clear and re-enter everything in each box.
One more think to try, view the actual compile command line that is being used:
Code::Blocks can output a build log. Settings->Compiler and debugger->Global compiler settings->{slide tabs to the right}->Build options tab->Save build log to HTML. Turn this feature on, then view the log after your next attempt. There may be something there pointing to the problem.
Consider the following CUDA program, in a file named foo.cu:
#include <cooperative_groups.h>
#include <stdio.h>
__global__ void my_kernel() {
auto g = cooperative_groups::this_grid();
g.sync();
}
int main(int, char **) {
cudaLaunchCooperativeKernel( (const void*) my_kernel, 2, 2, nullptr, 0, nullptr);
cudaDeviceSynchronize();
}
This program needs to be compiled with -rdc=true (see this question); and needs to be explicitly linked against libcudadevrt. Ok, no problem... or is it?
$ nvcc -rdc=true -o foo -gencode arch=compute_61,code=sm_61 foo.cu -lcudadevrt
nvlink error : Undefined reference to 'cudaCGGetIntrinsicHandle' in '/tmp/tmpxft_000036ec_00000000-10_foo.o'
nvlink error : Undefined reference to 'cudaCGSynchronizeGrid' in '/tmp/tmpxft_000036ec_00000000-10_foo.o'
Only if I explicitly add the library's folder with -L/usr/lib/x86_64-linux-gnu, is it willing to build my program.
This is strange, because all of the CUDA libraries on my system are in that folder. Why isn't NVCC/nvlink looking in there?
Notes:
I'm using Devuan GNU/Linux 3.0.
CUDA 10.1 is installed as a distribution package.
An x86_64 machine with a GeForce 1050 Ti card.
NVCC, or perhaps nvlink, looks for paths in an environment variable named LIBRARIES. But - before doing so, the shell script /etc/nvcc.profile is executed (at least, it is on Devuan).
On Devuan 3.0, that file has a line saying:
LIBRARIES =+ $(_SPACE_) -L/usr/lib/x86_64-linux-gnu/stubs
so that's where your NVCC looks to by default.
You can therefore do one of two things:
Set the environment variable outside NVCC, e.g. in your ~/.profile or ~/.bashrc file:
export LIBRARIES=-L/usr/lib/x86_64-linux-gnu/
Change that nvcc.profile line to say:
LIBRARIES =+ $(_SPACE_) -L/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu/stubs
and NVCC will successfully build your binary.
I have been trying to create an installer using Inno Setup for my vb.net application.
This application has a prerequisite dependency on MySQL ODBC. So, I was thinking if I could check the system if MySQL ODBC is present, and install if not. Well, to be frank, I am a newbie programmer, and I know no hell about debian, which is the script language for InnoSetup.
I was looking for help since some time, through google and stuff, but couldn't find anything other than some examples, and tried coding the script myself.
Here's the script:
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{ID goes here}
AppName=DCS
AppVersion=1.0
;AppVerName=DCS 1.0
AppPublisher=Syed
DefaultDirName={pf}\DCS
DisableDirPage=yes
DefaultGroupName=DCS
DisableProgramGroupPage=yes
OutputBaseFilename=setup
SetupIconFile=C:\logo.ico
Compression=lzma
SolidCompression=yes
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "C:\VS12\Projects\DCS\bin\Debug\DCS.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\VS12\Projects\DCS\bin\Debug\DCS.vshost.exe.config"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\VS12\Projects\DCS\bin\Debug\DCS.vshost.exe.manifest"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\VS12\Projects\DCS\bin\Debug\DCS.application"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\VS12\Projects\DCS\bin\Debug\DCS.exe.config"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\VS12\Projects\DCS\bin\Debug\DCS.exe.manifest"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\VS12\Projects\DCS\bin\Debug\DCS.pdb"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\VS12\Projects\DCS\bin\Debug\DCS.vshost.application"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\VS12\Projects\DCS\bin\Debug\DCS.vshost.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\VS12\Projects\DCS\bin\Debug\DCS.xml"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\VS12\Projects\DCS\bin\Debug\mysql-connector-odbc-5.1.12-win32.msi"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[code]
function IsMySQLOdbcInstalled(): boolean;
begin
If NOT RegKeyExists(HKEY_LOCAL_MACHINE, 'Software\ODBC\ODBCINST.INI\MySQL ODBC 5.1 Driver') then
Result := True
Else
Result := False;
end;
[Icons]
Name: "{group}\DCS"; Filename: "{app}\DCS.exe"
Name: "{commondesktop}\DCS"; Filename: "{app}\DCS.exe"; Tasks: desktopicon
[Run]
Filename: {src}\mysql-connector-odbc-5.1.12-win32.msi; Check: IsMySQLOdbcInstalled()
Filename: "{app}\DCS.exe"; Description: "{cm:LaunchProgram,DCS}"; Flags: nowait postinstall skipifsilent
Now, the compile goes fine, and generates a setup.exe executable. When run, the app DCS gets installed, but the MySQL ODBC doesn't and gives an error,
Unable to execute file:
'Output path'\mysql-connector-odbc-5.1.12-win32.msi
Create Process failed; code2.
The system cannot find the file specified.
OK
I thought the output folder needs the mysql-connector-odbc msi installation folder. Just to check, I copied it manually, recompiled and ran setup, only to get the same, but with some change:
Unable to execute file:
'Output path'\mysql-connector-odbc-5.1.12-win32.msi
Create Process failed; code193.
%1 is not a vaild Win32 application.
OK
And also, I wanted the installer to check for the MySQL ODBC driver before any installation proceeds, but here, it does so after the main application install. Can anyone please help me correct this script?
Thanks
The problem lies in your [Run] section. You're going to execute that MySQL ODBC installer from the {src} path. Since you copy your mysql-connector-odbc-5.1.12-win32.msi installer file to the {app} folder, you must run it from the same. Fix your [Run] section of the script this way:
[Run]
; on the following line, run the executable from the {app} directory instead
; of {src}; the {src} folder is the folder in which the Setup files are located
; since it is not an *.exe file, you must also specify the shellexec flag
Filename: {app}\mysql-connector-odbc-5.1.12-win32.msi; Check: IsMySQLOdbcInstalled(); Flags: shellexec
Filename: "{app}\DCS.exe"; Description: "{cm:LaunchProgram,DCS}"; Flags: nowait postinstall skipifsilent
Update:
To meet your additional requirement, run the ODBC driver installer before the main installation process, I've made the following script example (there are kept only parts relevant to the ODBC driver setup).
Anyway, I guess it might be less annoying if you run the ODBC driver installer in some silent mode with some default setting, so it won't offer wizard to the user if there is some (but that's much wider topic for this question; there will be parameters to control the ODBC driver installer, and those you can pass to the second parameter of the Exec function maybe telling the show window flag to be SW_HIDE instead of SW_SHOWNORMAL, which will keep it hidden from user). Please note, this code is untested:
[Setup]
AppName=DCS
AppVersion=1.0
DefaultDirName={pf}\DCS
[Files]
; keep just the only one flag, "dontcopy"; it will tell the installer to not copy
; this file entry to the target machine, but will be part of the setup binary and
; available for manual extracting by using the ExtractTemporaryFile(s) function
Source: "C:\VS12\Projects\DCS\bin\Debug\mysql-connector-odbc-5.1.12-win32.msi"; Flags: dontcopy
[Run]
; remove the ODBC driver installer entry from [Run] section since the [Run] section
; is executed after the installation is succesfully finished and your requirement is
; to run it before the installation process
; Filename: {app}\mysql-connector-odbc-5.1.12-win32.msi; Check: IsMySQLOdbcInstalled()
[Code]
function IsMySQLODBC51Installed: Boolean;
begin
// the result was inverted in the original code; the original function returned
// True if the ODBC driver was not installed, False otherwise, and according to
// the function name it should be vice-versa
Result := RegKeyExists(HKEY_LOCAL_MACHINE, 'Software\ODBC\ODBCINST.INI\MySQL ODBC 5.1 Driver');
end;
procedure CurStepChanged(CurStep: TSetupStep);
var
ResultCode: Integer;
begin
// if we are right before the main installation starts and ODBC driver is not yet
// installed, then...
if (CurStep = ssInstall) and not IsMySQLODBC51Installed then
begin
// now extract the ODBC installaer to the Inno Setup's temporary folder
ExtractTemporaryFile('mysql-connector-odbc-5.1.12-win32.msi');
// and execute the ODBC driver installation (it is necessary to use ShellExec
// since it is not an *.exe file); if the execution fails, then...
if not ShellExec('', ExpandConstant('{tmp}\mysql-connector-odbc-5.1.12-win32.msi'), '', '',
SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode) then
begin
// show the error message with exit code
MsgBox('MySQL ODBC Driver setup failed!' + #13#10 + 'Exit code: ' + IntToStr(ResultCode) +
'; ' + SysErrorMessage(ResultCode), mbError, MB_OK);
// here you can optionally call Abort to abort the upcoming installation process
// so if you uncomment the following line, the main installation will not run if
// the ODBC driver installer execution failed
// Abort;
end;
end;
end;
I am connecting the Mysql using c program in eclipse, I am using CYGWIN compiler to compile program. I have installed the mysql c connector and added the include files to the compiler and linker
but i am getting error
**** Build of configuration Debug for project DbConnectionC ****
make all
Building file: ../connection.c
Invoking: Cygwin C Compiler
gcc -I"C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include" -include"C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include\mysql.h" -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"connection.d" -MT"connection.d" -o "connection.o" "../connection.c"
cygwin warning:
MS-DOS style path detected: D:\java\workspace\DbConnectionC\Debug
Preferred POSIX equivalent is: /cygdrive/d/java/workspace/DbConnectionC/Debug
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
../connection.c: In function `main':
../connection.c:57: warning: char format, different type arg (arg 2)
../connection.c:57: warning: char format, different type arg (arg 2)
../connection.c:61: warning: char format, different type arg (arg 2)
../connection.c:61: warning: char format, different type arg (arg 2)
Finished building: ../connection.c
Building target: DbConnectionC.exe
Invoking: Cygwin C Linker
gcc -L"C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\lib\opt" -o "DbConnectionC.exe" ./connection.o -llibmysql.lib -lmysqlclient.lib
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find -llibmysql.lib
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find -lmysqlclient.lib
collect2: ld returned 1 exit status
make: *** [DbConnectionC.exe] Error 1
makefile:29: recipe for target `DbConnectionC.exe' failed
**** Build Finished ****
Please help me on this
thanks in advance
In the first part you have some warnings about possible problems:
../connection.c:39: warning: implicit declaration of function `exit'
This means function exit() is not declared, your source needs an #include <stdlib.h>
../connection.c:46: warning: control reaches end of non-void function
You don't return a value at the end of main(), add a return 0; if the program succeeds.
In the second part are linker warnings:
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find -llibmysql.lib
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find -lmysqlclient.lib
which means the linker needs a path to the libraries or the libraries do not exist or the library names are misspelled.
One possible solution is using -lmysql -lmysqlclient instead of -llibmysql.lib -lmysqlclient.lib, but I'm not that familiar with Windows.
Having said that, I suggest strongly, you look at https://stackoverflow.com/tags/c/info and look at some book links.
On OpenSuse 11.2, I successfully compiled, linked, and ran the following code which installs a data source for a MySQL database with unixODBC:
#include <iostream>
#include <sql.h>
#include <sqlext.h>
#include <odbcinst.h>
/* Add a data source for the following MySQL db: db=testdb, username=test, password = test. */
void inst()
{
BOOL ret = SQLConfigDataSource(NULL, ODBC_ADD_DSN, "MySQL driver",
"DSN=mysource\0UID=test\0PWD=test\0DATABASE=testdb\0\0");
if (!ret) {
DWORD errCode;
char errBuf[SQL_MAX_MESSAGE_LENGTH];
WORD msgLen;
SQLInstallerError(1, &errCode, errBuf, SQL_MAX_MESSAGE_LENGTH, &msgLen);
std::cerr << errBuf << std::endl;
}
}
int main()
{
inst();
return 0;
}
With the same code on Debian Lenny, I have had problems. First, I compiled this code the following way:
c++ -o main main.cc -lodbc -lodbcinst -L/usr/lib/odbc -lmyodbc
It went ok. But when I attempted to run the resulting binary, I got a linker error which in fact was confirmed by typing ldd main:
libmyodbc3_r-3.51.15.so => not found
Although I correctly installed unixODBC and the associated MySQL driver (myodbc) on my host (Debian Lenny) the simplest way (i.e. via aptitude), I could not find this shared library.
I wrongly thought, well, I will create a symlink on /usr/lib/odbc/libmyodbc.so. Anyway now my program returns the following message:
General installer error
So I feel the file libmyodbc3_r-3.51.15.so is really missing.
Note: on Debian Lenny, the version of unixODBC is 2.2.11, and the version of MySQL is 5.0.51a
Anyone ever ran into such a situation ? Any help would be appreciated.
The option
-L/usr/lib/odbc
tells the compiler where to find the library for linking.
But the system doesn't know where to find the library when you run the executable.
You need to either statically link against libmyodbc, or tell the system where to find the library.
The first can be done by changing
-lmyodbc
to
-static -lmyodbc
The second can be done by editing /etc/ld.so.conf (or adding to /etc/ld.so.conf.d) and re-running ldconfig or by setting the LD_LIBRARY_PATH environment variable to include /usr/lib/odbc